mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 07:08:11 +00:00
[SBI] Crash occurs when ENUM in the MAP (#2103)
This commit is contained in:
parent
ce668c556c
commit
969c116e77
1097 changed files with 266728 additions and 42047 deletions
|
|
@ -18,20 +18,25 @@ OpenAPI_dnf_t *OpenAPI_dnf_create(
|
|||
|
||||
void OpenAPI_dnf_free(OpenAPI_dnf_t *dnf)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == dnf) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_list_for_each(dnf->dnf_units, node) {
|
||||
OpenAPI_dnf_unit_free(node->data);
|
||||
if (dnf->dnf_units) {
|
||||
OpenAPI_list_for_each(dnf->dnf_units, node) {
|
||||
OpenAPI_dnf_unit_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(dnf->dnf_units);
|
||||
dnf->dnf_units = NULL;
|
||||
}
|
||||
OpenAPI_list_free(dnf->dnf_units);
|
||||
ogs_free(dnf);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_dnf_convertToJSON(OpenAPI_dnf_t *dnf)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (dnf == NULL) {
|
||||
ogs_error("OpenAPI_dnf_convertToJSON() failed [Dnf]");
|
||||
|
|
@ -39,22 +44,22 @@ cJSON *OpenAPI_dnf_convertToJSON(OpenAPI_dnf_t *dnf)
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!dnf->dnf_units) {
|
||||
ogs_error("OpenAPI_dnf_convertToJSON() failed [dnf_units]");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *dnf_unitsList = cJSON_AddArrayToObject(item, "dnfUnits");
|
||||
if (dnf_unitsList == NULL) {
|
||||
ogs_error("OpenAPI_dnf_convertToJSON() failed [dnf_units]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *dnf_units_node;
|
||||
if (dnf->dnf_units) {
|
||||
OpenAPI_list_for_each(dnf->dnf_units, dnf_units_node) {
|
||||
cJSON *itemLocal = OpenAPI_dnf_unit_convertToJSON(dnf_units_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_dnf_convertToJSON() failed [dnf_units]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(dnf_unitsList, itemLocal);
|
||||
OpenAPI_list_for_each(dnf->dnf_units, node) {
|
||||
cJSON *itemLocal = OpenAPI_dnf_unit_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_dnf_convertToJSON() failed [dnf_units]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(dnf_unitsList, itemLocal);
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
@ -64,43 +69,49 @@ end:
|
|||
OpenAPI_dnf_t *OpenAPI_dnf_parseFromJSON(cJSON *dnfJSON)
|
||||
{
|
||||
OpenAPI_dnf_t *dnf_local_var = NULL;
|
||||
cJSON *dnf_units = cJSON_GetObjectItemCaseSensitive(dnfJSON, "dnfUnits");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *dnf_units = NULL;
|
||||
OpenAPI_list_t *dnf_unitsList = NULL;
|
||||
dnf_units = cJSON_GetObjectItemCaseSensitive(dnfJSON, "dnfUnits");
|
||||
if (!dnf_units) {
|
||||
ogs_error("OpenAPI_dnf_parseFromJSON() failed [dnf_units]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_t *dnf_unitsList;
|
||||
cJSON *dnf_units_local_nonprimitive;
|
||||
if (!cJSON_IsArray(dnf_units)){
|
||||
ogs_error("OpenAPI_dnf_parseFromJSON() failed [dnf_units]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
dnf_unitsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(dnf_units_local_nonprimitive, dnf_units ) {
|
||||
if (!cJSON_IsObject(dnf_units_local_nonprimitive)) {
|
||||
cJSON *dnf_units_local = NULL;
|
||||
if (!cJSON_IsArray(dnf_units)) {
|
||||
ogs_error("OpenAPI_dnf_parseFromJSON() failed [dnf_units]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_dnf_unit_t *dnf_unitsItem = OpenAPI_dnf_unit_parseFromJSON(dnf_units_local_nonprimitive);
|
||||
|
||||
if (!dnf_unitsItem) {
|
||||
ogs_error("No dnf_unitsItem");
|
||||
OpenAPI_list_free(dnf_unitsList);
|
||||
goto end;
|
||||
dnf_unitsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(dnf_units_local, dnf_units) {
|
||||
if (!cJSON_IsObject(dnf_units_local)) {
|
||||
ogs_error("OpenAPI_dnf_parseFromJSON() failed [dnf_units]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_dnf_unit_t *dnf_unitsItem = OpenAPI_dnf_unit_parseFromJSON(dnf_units_local);
|
||||
if (!dnf_unitsItem) {
|
||||
ogs_error("No dnf_unitsItem");
|
||||
OpenAPI_list_free(dnf_unitsList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(dnf_unitsList, dnf_unitsItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(dnf_unitsList, dnf_unitsItem);
|
||||
}
|
||||
|
||||
dnf_local_var = OpenAPI_dnf_create (
|
||||
dnf_unitsList
|
||||
);
|
||||
|
||||
return dnf_local_var;
|
||||
end:
|
||||
if (dnf_unitsList) {
|
||||
OpenAPI_list_for_each(dnf_unitsList, node) {
|
||||
OpenAPI_dnf_unit_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(dnf_unitsList);
|
||||
dnf_unitsList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue