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
|
|
@ -26,22 +26,33 @@ OpenAPI_notification_data_t *OpenAPI_notification_data_create(
|
|||
|
||||
void OpenAPI_notification_data_free(OpenAPI_notification_data_t *notification_data)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == notification_data) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(notification_data->nf_instance_uri);
|
||||
OpenAPI_nf_profile_free(notification_data->nf_profile);
|
||||
OpenAPI_list_for_each(notification_data->profile_changes, node) {
|
||||
OpenAPI_change_item_free(node->data);
|
||||
if (notification_data->nf_instance_uri) {
|
||||
ogs_free(notification_data->nf_instance_uri);
|
||||
notification_data->nf_instance_uri = NULL;
|
||||
}
|
||||
if (notification_data->nf_profile) {
|
||||
OpenAPI_nf_profile_free(notification_data->nf_profile);
|
||||
notification_data->nf_profile = NULL;
|
||||
}
|
||||
if (notification_data->profile_changes) {
|
||||
OpenAPI_list_for_each(notification_data->profile_changes, node) {
|
||||
OpenAPI_change_item_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(notification_data->profile_changes);
|
||||
notification_data->profile_changes = NULL;
|
||||
}
|
||||
OpenAPI_list_free(notification_data->profile_changes);
|
||||
ogs_free(notification_data);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_notification_data_convertToJSON(OpenAPI_notification_data_t *notification_data)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (notification_data == NULL) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [NotificationData]");
|
||||
|
|
@ -49,11 +60,19 @@ cJSON *OpenAPI_notification_data_convertToJSON(OpenAPI_notification_data_t *noti
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (notification_data->event == OpenAPI_notification_event_type_NULL) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [event]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "event", OpenAPI_notification_event_type_ToString(notification_data->event)) == NULL) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [event]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!notification_data->nf_instance_uri) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [nf_instance_uri]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "nfInstanceUri", notification_data->nf_instance_uri) == NULL) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [nf_instance_uri]");
|
||||
goto end;
|
||||
|
|
@ -78,21 +97,17 @@ cJSON *OpenAPI_notification_data_convertToJSON(OpenAPI_notification_data_t *noti
|
|||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [profile_changes]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *profile_changes_node;
|
||||
if (notification_data->profile_changes) {
|
||||
OpenAPI_list_for_each(notification_data->profile_changes, profile_changes_node) {
|
||||
cJSON *itemLocal = OpenAPI_change_item_convertToJSON(profile_changes_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [profile_changes]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(profile_changesList, itemLocal);
|
||||
OpenAPI_list_for_each(notification_data->profile_changes, node) {
|
||||
cJSON *itemLocal = OpenAPI_change_item_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [profile_changes]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(profile_changesList, itemLocal);
|
||||
}
|
||||
}
|
||||
|
||||
if (notification_data->condition_event) {
|
||||
if (notification_data->condition_event != OpenAPI_condition_event_type_NULL) {
|
||||
if (cJSON_AddStringToObject(item, "conditionEvent", OpenAPI_condition_event_type_ToString(notification_data->condition_event)) == NULL) {
|
||||
ogs_error("OpenAPI_notification_data_convertToJSON() failed [condition_event]");
|
||||
goto end;
|
||||
|
|
@ -106,69 +121,68 @@ end:
|
|||
OpenAPI_notification_data_t *OpenAPI_notification_data_parseFromJSON(cJSON *notification_dataJSON)
|
||||
{
|
||||
OpenAPI_notification_data_t *notification_data_local_var = NULL;
|
||||
cJSON *event = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "event");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *event = NULL;
|
||||
OpenAPI_notification_event_type_e eventVariable = 0;
|
||||
cJSON *nf_instance_uri = NULL;
|
||||
cJSON *nf_profile = NULL;
|
||||
OpenAPI_nf_profile_t *nf_profile_local_nonprim = NULL;
|
||||
cJSON *profile_changes = NULL;
|
||||
OpenAPI_list_t *profile_changesList = NULL;
|
||||
cJSON *condition_event = NULL;
|
||||
OpenAPI_condition_event_type_e condition_eventVariable = 0;
|
||||
event = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "event");
|
||||
if (!event) {
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [event]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_notification_event_type_e eventVariable;
|
||||
if (!cJSON_IsString(event)) {
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [event]");
|
||||
goto end;
|
||||
}
|
||||
eventVariable = OpenAPI_notification_event_type_FromString(event->valuestring);
|
||||
|
||||
cJSON *nf_instance_uri = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "nfInstanceUri");
|
||||
nf_instance_uri = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "nfInstanceUri");
|
||||
if (!nf_instance_uri) {
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [nf_instance_uri]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(nf_instance_uri)) {
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [nf_instance_uri]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *nf_profile = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "nfProfile");
|
||||
|
||||
OpenAPI_nf_profile_t *nf_profile_local_nonprim = NULL;
|
||||
nf_profile = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "nfProfile");
|
||||
if (nf_profile) {
|
||||
nf_profile_local_nonprim = OpenAPI_nf_profile_parseFromJSON(nf_profile);
|
||||
}
|
||||
|
||||
cJSON *profile_changes = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "profileChanges");
|
||||
|
||||
OpenAPI_list_t *profile_changesList;
|
||||
profile_changes = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "profileChanges");
|
||||
if (profile_changes) {
|
||||
cJSON *profile_changes_local_nonprimitive;
|
||||
if (!cJSON_IsArray(profile_changes)){
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [profile_changes]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
profile_changesList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(profile_changes_local_nonprimitive, profile_changes ) {
|
||||
if (!cJSON_IsObject(profile_changes_local_nonprimitive)) {
|
||||
cJSON *profile_changes_local = NULL;
|
||||
if (!cJSON_IsArray(profile_changes)) {
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [profile_changes]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_change_item_t *profile_changesItem = OpenAPI_change_item_parseFromJSON(profile_changes_local_nonprimitive);
|
||||
|
||||
if (!profile_changesItem) {
|
||||
ogs_error("No profile_changesItem");
|
||||
OpenAPI_list_free(profile_changesList);
|
||||
goto end;
|
||||
profile_changesList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(profile_changes_local, profile_changes) {
|
||||
if (!cJSON_IsObject(profile_changes_local)) {
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [profile_changes]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_change_item_t *profile_changesItem = OpenAPI_change_item_parseFromJSON(profile_changes_local);
|
||||
if (!profile_changesItem) {
|
||||
ogs_error("No profile_changesItem");
|
||||
OpenAPI_list_free(profile_changesList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(profile_changesList, profile_changesItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(profile_changesList, profile_changesItem);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *condition_event = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "conditionEvent");
|
||||
|
||||
OpenAPI_condition_event_type_e condition_eventVariable;
|
||||
condition_event = cJSON_GetObjectItemCaseSensitive(notification_dataJSON, "conditionEvent");
|
||||
if (condition_event) {
|
||||
if (!cJSON_IsString(condition_event)) {
|
||||
ogs_error("OpenAPI_notification_data_parseFromJSON() failed [condition_event]");
|
||||
|
|
@ -187,6 +201,17 @@ OpenAPI_notification_data_t *OpenAPI_notification_data_parseFromJSON(cJSON *noti
|
|||
|
||||
return notification_data_local_var;
|
||||
end:
|
||||
if (nf_profile_local_nonprim) {
|
||||
OpenAPI_nf_profile_free(nf_profile_local_nonprim);
|
||||
nf_profile_local_nonprim = NULL;
|
||||
}
|
||||
if (profile_changesList) {
|
||||
OpenAPI_list_for_each(profile_changesList, node) {
|
||||
OpenAPI_change_item_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(profile_changesList);
|
||||
profile_changesList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue