mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 22:30:09 +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_notification_item_t *OpenAPI_notification_item_create(
|
|||
|
||||
void OpenAPI_notification_item_free(OpenAPI_notification_item_t *notification_item)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == notification_item) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(notification_item->resource_id);
|
||||
OpenAPI_list_for_each(notification_item->notif_items, node) {
|
||||
OpenAPI_updated_item_free(node->data);
|
||||
if (notification_item->resource_id) {
|
||||
ogs_free(notification_item->resource_id);
|
||||
notification_item->resource_id = NULL;
|
||||
}
|
||||
if (notification_item->notif_items) {
|
||||
OpenAPI_list_for_each(notification_item->notif_items, node) {
|
||||
OpenAPI_updated_item_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(notification_item->notif_items);
|
||||
notification_item->notif_items = NULL;
|
||||
}
|
||||
OpenAPI_list_free(notification_item->notif_items);
|
||||
ogs_free(notification_item);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_notification_item_convertToJSON(OpenAPI_notification_item_t *notification_item)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (notification_item == NULL) {
|
||||
ogs_error("OpenAPI_notification_item_convertToJSON() failed [NotificationItem]");
|
||||
|
|
@ -42,27 +50,31 @@ cJSON *OpenAPI_notification_item_convertToJSON(OpenAPI_notification_item_t *noti
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!notification_item->resource_id) {
|
||||
ogs_error("OpenAPI_notification_item_convertToJSON() failed [resource_id]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "resourceId", notification_item->resource_id) == NULL) {
|
||||
ogs_error("OpenAPI_notification_item_convertToJSON() failed [resource_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!notification_item->notif_items) {
|
||||
ogs_error("OpenAPI_notification_item_convertToJSON() failed [notif_items]");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *notif_itemsList = cJSON_AddArrayToObject(item, "notifItems");
|
||||
if (notif_itemsList == NULL) {
|
||||
ogs_error("OpenAPI_notification_item_convertToJSON() failed [notif_items]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *notif_items_node;
|
||||
if (notification_item->notif_items) {
|
||||
OpenAPI_list_for_each(notification_item->notif_items, notif_items_node) {
|
||||
cJSON *itemLocal = OpenAPI_updated_item_convertToJSON(notif_items_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_notification_item_convertToJSON() failed [notif_items]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(notif_itemsList, itemLocal);
|
||||
OpenAPI_list_for_each(notification_item->notif_items, node) {
|
||||
cJSON *itemLocal = OpenAPI_updated_item_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_notification_item_convertToJSON() failed [notif_items]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(notif_itemsList, itemLocal);
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
@ -72,48 +84,47 @@ end:
|
|||
OpenAPI_notification_item_t *OpenAPI_notification_item_parseFromJSON(cJSON *notification_itemJSON)
|
||||
{
|
||||
OpenAPI_notification_item_t *notification_item_local_var = NULL;
|
||||
cJSON *resource_id = cJSON_GetObjectItemCaseSensitive(notification_itemJSON, "resourceId");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *resource_id = NULL;
|
||||
cJSON *notif_items = NULL;
|
||||
OpenAPI_list_t *notif_itemsList = NULL;
|
||||
resource_id = cJSON_GetObjectItemCaseSensitive(notification_itemJSON, "resourceId");
|
||||
if (!resource_id) {
|
||||
ogs_error("OpenAPI_notification_item_parseFromJSON() failed [resource_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(resource_id)) {
|
||||
ogs_error("OpenAPI_notification_item_parseFromJSON() failed [resource_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *notif_items = cJSON_GetObjectItemCaseSensitive(notification_itemJSON, "notifItems");
|
||||
notif_items = cJSON_GetObjectItemCaseSensitive(notification_itemJSON, "notifItems");
|
||||
if (!notif_items) {
|
||||
ogs_error("OpenAPI_notification_item_parseFromJSON() failed [notif_items]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_t *notif_itemsList;
|
||||
cJSON *notif_items_local_nonprimitive;
|
||||
if (!cJSON_IsArray(notif_items)){
|
||||
ogs_error("OpenAPI_notification_item_parseFromJSON() failed [notif_items]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
notif_itemsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(notif_items_local_nonprimitive, notif_items ) {
|
||||
if (!cJSON_IsObject(notif_items_local_nonprimitive)) {
|
||||
cJSON *notif_items_local = NULL;
|
||||
if (!cJSON_IsArray(notif_items)) {
|
||||
ogs_error("OpenAPI_notification_item_parseFromJSON() failed [notif_items]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_updated_item_t *notif_itemsItem = OpenAPI_updated_item_parseFromJSON(notif_items_local_nonprimitive);
|
||||
|
||||
if (!notif_itemsItem) {
|
||||
ogs_error("No notif_itemsItem");
|
||||
OpenAPI_list_free(notif_itemsList);
|
||||
goto end;
|
||||
notif_itemsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(notif_items_local, notif_items) {
|
||||
if (!cJSON_IsObject(notif_items_local)) {
|
||||
ogs_error("OpenAPI_notification_item_parseFromJSON() failed [notif_items]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_updated_item_t *notif_itemsItem = OpenAPI_updated_item_parseFromJSON(notif_items_local);
|
||||
if (!notif_itemsItem) {
|
||||
ogs_error("No notif_itemsItem");
|
||||
OpenAPI_list_free(notif_itemsList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(notif_itemsList, notif_itemsItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(notif_itemsList, notif_itemsItem);
|
||||
}
|
||||
|
||||
notification_item_local_var = OpenAPI_notification_item_create (
|
||||
ogs_strdup(resource_id->valuestring),
|
||||
notif_itemsList
|
||||
|
|
@ -121,6 +132,13 @@ OpenAPI_notification_item_t *OpenAPI_notification_item_parseFromJSON(cJSON *noti
|
|||
|
||||
return notification_item_local_var;
|
||||
end:
|
||||
if (notif_itemsList) {
|
||||
OpenAPI_list_for_each(notif_itemsList, node) {
|
||||
OpenAPI_updated_item_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(notif_itemsList);
|
||||
notif_itemsList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue