[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_dnf_unit_t *OpenAPI_dnf_unit_create(
void OpenAPI_dnf_unit_free(OpenAPI_dnf_unit_t *dnf_unit)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == dnf_unit) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_list_for_each(dnf_unit->dnf_unit, node) {
OpenAPI_atom_free(node->data);
if (dnf_unit->dnf_unit) {
OpenAPI_list_for_each(dnf_unit->dnf_unit, node) {
OpenAPI_atom_free(node->data);
}
OpenAPI_list_free(dnf_unit->dnf_unit);
dnf_unit->dnf_unit = NULL;
}
OpenAPI_list_free(dnf_unit->dnf_unit);
ogs_free(dnf_unit);
}
cJSON *OpenAPI_dnf_unit_convertToJSON(OpenAPI_dnf_unit_t *dnf_unit)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (dnf_unit == NULL) {
ogs_error("OpenAPI_dnf_unit_convertToJSON() failed [DnfUnit]");
@ -39,22 +44,22 @@ cJSON *OpenAPI_dnf_unit_convertToJSON(OpenAPI_dnf_unit_t *dnf_unit)
}
item = cJSON_CreateObject();
if (!dnf_unit->dnf_unit) {
ogs_error("OpenAPI_dnf_unit_convertToJSON() failed [dnf_unit]");
return NULL;
}
cJSON *dnf_unitList = cJSON_AddArrayToObject(item, "dnfUnit");
if (dnf_unitList == NULL) {
ogs_error("OpenAPI_dnf_unit_convertToJSON() failed [dnf_unit]");
goto end;
}
OpenAPI_lnode_t *dnf_unit_node;
if (dnf_unit->dnf_unit) {
OpenAPI_list_for_each(dnf_unit->dnf_unit, dnf_unit_node) {
cJSON *itemLocal = OpenAPI_atom_convertToJSON(dnf_unit_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_dnf_unit_convertToJSON() failed [dnf_unit]");
goto end;
}
cJSON_AddItemToArray(dnf_unitList, itemLocal);
OpenAPI_list_for_each(dnf_unit->dnf_unit, node) {
cJSON *itemLocal = OpenAPI_atom_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_dnf_unit_convertToJSON() failed [dnf_unit]");
goto end;
}
cJSON_AddItemToArray(dnf_unitList, itemLocal);
}
end:
@ -64,43 +69,49 @@ end:
OpenAPI_dnf_unit_t *OpenAPI_dnf_unit_parseFromJSON(cJSON *dnf_unitJSON)
{
OpenAPI_dnf_unit_t *dnf_unit_local_var = NULL;
cJSON *dnf_unit = cJSON_GetObjectItemCaseSensitive(dnf_unitJSON, "dnfUnit");
OpenAPI_lnode_t *node = NULL;
cJSON *dnf_unit = NULL;
OpenAPI_list_t *dnf_unitList = NULL;
dnf_unit = cJSON_GetObjectItemCaseSensitive(dnf_unitJSON, "dnfUnit");
if (!dnf_unit) {
ogs_error("OpenAPI_dnf_unit_parseFromJSON() failed [dnf_unit]");
goto end;
}
OpenAPI_list_t *dnf_unitList;
cJSON *dnf_unit_local_nonprimitive;
if (!cJSON_IsArray(dnf_unit)){
ogs_error("OpenAPI_dnf_unit_parseFromJSON() failed [dnf_unit]");
goto end;
}
dnf_unitList = OpenAPI_list_create();
cJSON_ArrayForEach(dnf_unit_local_nonprimitive, dnf_unit ) {
if (!cJSON_IsObject(dnf_unit_local_nonprimitive)) {
cJSON *dnf_unit_local = NULL;
if (!cJSON_IsArray(dnf_unit)) {
ogs_error("OpenAPI_dnf_unit_parseFromJSON() failed [dnf_unit]");
goto end;
}
OpenAPI_atom_t *dnf_unitItem = OpenAPI_atom_parseFromJSON(dnf_unit_local_nonprimitive);
if (!dnf_unitItem) {
ogs_error("No dnf_unitItem");
OpenAPI_list_free(dnf_unitList);
goto end;
dnf_unitList = OpenAPI_list_create();
cJSON_ArrayForEach(dnf_unit_local, dnf_unit) {
if (!cJSON_IsObject(dnf_unit_local)) {
ogs_error("OpenAPI_dnf_unit_parseFromJSON() failed [dnf_unit]");
goto end;
}
OpenAPI_atom_t *dnf_unitItem = OpenAPI_atom_parseFromJSON(dnf_unit_local);
if (!dnf_unitItem) {
ogs_error("No dnf_unitItem");
OpenAPI_list_free(dnf_unitList);
goto end;
}
OpenAPI_list_add(dnf_unitList, dnf_unitItem);
}
OpenAPI_list_add(dnf_unitList, dnf_unitItem);
}
dnf_unit_local_var = OpenAPI_dnf_unit_create (
dnf_unitList
);
return dnf_unit_local_var;
end:
if (dnf_unitList) {
OpenAPI_list_for_each(dnf_unitList, node) {
OpenAPI_atom_free(node->data);
}
OpenAPI_list_free(dnf_unitList);
dnf_unitList = NULL;
}
return NULL;
}