[SBI] Crash occurs when ENUM in the MAP (#2103)

This commit is contained in:
Sukchan Lee 2023-03-01 17:50:25 +09:00
parent ce668c556c
commit 969c116e77
1097 changed files with 266728 additions and 42047 deletions

View file

@ -18,20 +18,25 @@ OpenAPI_tac_info_t *OpenAPI_tac_info_create(
void OpenAPI_tac_info_free(OpenAPI_tac_info_t *tac_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == tac_info) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_list_for_each(tac_info->tac_list, node) {
ogs_free(node->data);
if (tac_info->tac_list) {
OpenAPI_list_for_each(tac_info->tac_list, node) {
ogs_free(node->data);
}
OpenAPI_list_free(tac_info->tac_list);
tac_info->tac_list = NULL;
}
OpenAPI_list_free(tac_info->tac_list);
ogs_free(tac_info);
}
cJSON *OpenAPI_tac_info_convertToJSON(OpenAPI_tac_info_t *tac_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (tac_info == NULL) {
ogs_error("OpenAPI_tac_info_convertToJSON() failed [TacInfo]");
@ -39,19 +44,21 @@ cJSON *OpenAPI_tac_info_convertToJSON(OpenAPI_tac_info_t *tac_info)
}
item = cJSON_CreateObject();
cJSON *tac_list = cJSON_AddArrayToObject(item, "tacList");
if (tac_list == NULL) {
if (!tac_info->tac_list) {
ogs_error("OpenAPI_tac_info_convertToJSON() failed [tac_list]");
return NULL;
}
cJSON *tac_listList = cJSON_AddArrayToObject(item, "tacList");
if (tac_listList == NULL) {
ogs_error("OpenAPI_tac_info_convertToJSON() failed [tac_list]");
goto end;
}
OpenAPI_lnode_t *tac_list_node;
OpenAPI_list_for_each(tac_info->tac_list, tac_list_node) {
if (cJSON_AddStringToObject(tac_list, "", (char*)tac_list_node->data) == NULL) {
ogs_error("OpenAPI_tac_info_convertToJSON() failed [tac_list]");
goto end;
OpenAPI_list_for_each(tac_info->tac_list, node) {
if (cJSON_AddStringToObject(tac_listList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_tac_info_convertToJSON() failed [tac_list]");
goto end;
}
}
}
end:
return item;
@ -60,27 +67,31 @@ end:
OpenAPI_tac_info_t *OpenAPI_tac_info_parseFromJSON(cJSON *tac_infoJSON)
{
OpenAPI_tac_info_t *tac_info_local_var = NULL;
cJSON *tac_list = cJSON_GetObjectItemCaseSensitive(tac_infoJSON, "tacList");
OpenAPI_lnode_t *node = NULL;
cJSON *tac_list = NULL;
OpenAPI_list_t *tac_listList = NULL;
tac_list = cJSON_GetObjectItemCaseSensitive(tac_infoJSON, "tacList");
if (!tac_list) {
ogs_error("OpenAPI_tac_info_parseFromJSON() failed [tac_list]");
goto end;
}
cJSON *tac_list_local = NULL;
if (!cJSON_IsArray(tac_list)) {
ogs_error("OpenAPI_tac_info_parseFromJSON() failed [tac_list]");
goto end;
}
OpenAPI_list_t *tac_listList;
cJSON *tac_list_local;
if (!cJSON_IsArray(tac_list)) {
ogs_error("OpenAPI_tac_info_parseFromJSON() failed [tac_list]");
goto end;
}
tac_listList = OpenAPI_list_create();
tac_listList = OpenAPI_list_create();
cJSON_ArrayForEach(tac_list_local, tac_list) {
if (!cJSON_IsString(tac_list_local)) {
ogs_error("OpenAPI_tac_info_parseFromJSON() failed [tac_list]");
goto end;
}
OpenAPI_list_add(tac_listList, ogs_strdup(tac_list_local->valuestring));
}
cJSON_ArrayForEach(tac_list_local, tac_list) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(tac_list_local)) {
ogs_error("OpenAPI_tac_info_parseFromJSON() failed [tac_list]");
goto end;
}
OpenAPI_list_add(tac_listList, ogs_strdup(tac_list_local->valuestring));
}
tac_info_local_var = OpenAPI_tac_info_create (
tac_listList
@ -88,6 +99,13 @@ OpenAPI_tac_info_t *OpenAPI_tac_info_parseFromJSON(cJSON *tac_infoJSON)
return tac_info_local_var;
end:
if (tac_listList) {
OpenAPI_list_for_each(tac_listList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(tac_listList);
tac_listList = NULL;
}
return NULL;
}