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
|
|
@ -20,21 +20,29 @@ OpenAPI_notify_item_t *OpenAPI_notify_item_create(
|
|||
|
||||
void OpenAPI_notify_item_free(OpenAPI_notify_item_t *notify_item)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == notify_item) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(notify_item->resource_id);
|
||||
OpenAPI_list_for_each(notify_item->changes, node) {
|
||||
OpenAPI_change_item_free(node->data);
|
||||
if (notify_item->resource_id) {
|
||||
ogs_free(notify_item->resource_id);
|
||||
notify_item->resource_id = NULL;
|
||||
}
|
||||
if (notify_item->changes) {
|
||||
OpenAPI_list_for_each(notify_item->changes, node) {
|
||||
OpenAPI_change_item_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(notify_item->changes);
|
||||
notify_item->changes = NULL;
|
||||
}
|
||||
OpenAPI_list_free(notify_item->changes);
|
||||
ogs_free(notify_item);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_notify_item_convertToJSON(OpenAPI_notify_item_t *notify_item)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (notify_item == NULL) {
|
||||
ogs_error("OpenAPI_notify_item_convertToJSON() failed [NotifyItem]");
|
||||
|
|
@ -42,27 +50,31 @@ cJSON *OpenAPI_notify_item_convertToJSON(OpenAPI_notify_item_t *notify_item)
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!notify_item->resource_id) {
|
||||
ogs_error("OpenAPI_notify_item_convertToJSON() failed [resource_id]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "resourceId", notify_item->resource_id) == NULL) {
|
||||
ogs_error("OpenAPI_notify_item_convertToJSON() failed [resource_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!notify_item->changes) {
|
||||
ogs_error("OpenAPI_notify_item_convertToJSON() failed [changes]");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *changesList = cJSON_AddArrayToObject(item, "changes");
|
||||
if (changesList == NULL) {
|
||||
ogs_error("OpenAPI_notify_item_convertToJSON() failed [changes]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *changes_node;
|
||||
if (notify_item->changes) {
|
||||
OpenAPI_list_for_each(notify_item->changes, changes_node) {
|
||||
cJSON *itemLocal = OpenAPI_change_item_convertToJSON(changes_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_notify_item_convertToJSON() failed [changes]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(changesList, itemLocal);
|
||||
OpenAPI_list_for_each(notify_item->changes, node) {
|
||||
cJSON *itemLocal = OpenAPI_change_item_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_notify_item_convertToJSON() failed [changes]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(changesList, itemLocal);
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
@ -72,48 +84,47 @@ end:
|
|||
OpenAPI_notify_item_t *OpenAPI_notify_item_parseFromJSON(cJSON *notify_itemJSON)
|
||||
{
|
||||
OpenAPI_notify_item_t *notify_item_local_var = NULL;
|
||||
cJSON *resource_id = cJSON_GetObjectItemCaseSensitive(notify_itemJSON, "resourceId");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *resource_id = NULL;
|
||||
cJSON *changes = NULL;
|
||||
OpenAPI_list_t *changesList = NULL;
|
||||
resource_id = cJSON_GetObjectItemCaseSensitive(notify_itemJSON, "resourceId");
|
||||
if (!resource_id) {
|
||||
ogs_error("OpenAPI_notify_item_parseFromJSON() failed [resource_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(resource_id)) {
|
||||
ogs_error("OpenAPI_notify_item_parseFromJSON() failed [resource_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *changes = cJSON_GetObjectItemCaseSensitive(notify_itemJSON, "changes");
|
||||
changes = cJSON_GetObjectItemCaseSensitive(notify_itemJSON, "changes");
|
||||
if (!changes) {
|
||||
ogs_error("OpenAPI_notify_item_parseFromJSON() failed [changes]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_t *changesList;
|
||||
cJSON *changes_local_nonprimitive;
|
||||
if (!cJSON_IsArray(changes)){
|
||||
ogs_error("OpenAPI_notify_item_parseFromJSON() failed [changes]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
changesList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(changes_local_nonprimitive, changes ) {
|
||||
if (!cJSON_IsObject(changes_local_nonprimitive)) {
|
||||
cJSON *changes_local = NULL;
|
||||
if (!cJSON_IsArray(changes)) {
|
||||
ogs_error("OpenAPI_notify_item_parseFromJSON() failed [changes]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_change_item_t *changesItem = OpenAPI_change_item_parseFromJSON(changes_local_nonprimitive);
|
||||
|
||||
if (!changesItem) {
|
||||
ogs_error("No changesItem");
|
||||
OpenAPI_list_free(changesList);
|
||||
goto end;
|
||||
changesList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(changes_local, changes) {
|
||||
if (!cJSON_IsObject(changes_local)) {
|
||||
ogs_error("OpenAPI_notify_item_parseFromJSON() failed [changes]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_change_item_t *changesItem = OpenAPI_change_item_parseFromJSON(changes_local);
|
||||
if (!changesItem) {
|
||||
ogs_error("No changesItem");
|
||||
OpenAPI_list_free(changesList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(changesList, changesItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(changesList, changesItem);
|
||||
}
|
||||
|
||||
notify_item_local_var = OpenAPI_notify_item_create (
|
||||
ogs_strdup(resource_id->valuestring),
|
||||
changesList
|
||||
|
|
@ -121,6 +132,13 @@ OpenAPI_notify_item_t *OpenAPI_notify_item_parseFromJSON(cJSON *notify_itemJSON)
|
|||
|
||||
return notify_item_local_var;
|
||||
end:
|
||||
if (changesList) {
|
||||
OpenAPI_list_for_each(changesList, node) {
|
||||
OpenAPI_change_item_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(changesList);
|
||||
changesList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue