mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-03 13:50:08 +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
|
|
@ -24,23 +24,37 @@ OpenAPI_exposure_data_subscription_t *OpenAPI_exposure_data_subscription_create(
|
|||
|
||||
void OpenAPI_exposure_data_subscription_free(OpenAPI_exposure_data_subscription_t *exposure_data_subscription)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == exposure_data_subscription) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(exposure_data_subscription->notification_uri);
|
||||
OpenAPI_list_for_each(exposure_data_subscription->monitored_resource_uris, node) {
|
||||
ogs_free(node->data);
|
||||
if (exposure_data_subscription->notification_uri) {
|
||||
ogs_free(exposure_data_subscription->notification_uri);
|
||||
exposure_data_subscription->notification_uri = NULL;
|
||||
}
|
||||
if (exposure_data_subscription->monitored_resource_uris) {
|
||||
OpenAPI_list_for_each(exposure_data_subscription->monitored_resource_uris, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(exposure_data_subscription->monitored_resource_uris);
|
||||
exposure_data_subscription->monitored_resource_uris = NULL;
|
||||
}
|
||||
if (exposure_data_subscription->expiry) {
|
||||
ogs_free(exposure_data_subscription->expiry);
|
||||
exposure_data_subscription->expiry = NULL;
|
||||
}
|
||||
if (exposure_data_subscription->supported_features) {
|
||||
ogs_free(exposure_data_subscription->supported_features);
|
||||
exposure_data_subscription->supported_features = NULL;
|
||||
}
|
||||
OpenAPI_list_free(exposure_data_subscription->monitored_resource_uris);
|
||||
ogs_free(exposure_data_subscription->expiry);
|
||||
ogs_free(exposure_data_subscription->supported_features);
|
||||
ogs_free(exposure_data_subscription);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_exposure_data_subscription_convertToJSON(OpenAPI_exposure_data_subscription_t *exposure_data_subscription)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (exposure_data_subscription == NULL) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_convertToJSON() failed [ExposureDataSubscription]");
|
||||
|
|
@ -48,24 +62,30 @@ cJSON *OpenAPI_exposure_data_subscription_convertToJSON(OpenAPI_exposure_data_su
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!exposure_data_subscription->notification_uri) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_convertToJSON() failed [notification_uri]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "notificationUri", exposure_data_subscription->notification_uri) == NULL) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_convertToJSON() failed [notification_uri]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *monitored_resource_uris = cJSON_AddArrayToObject(item, "monitoredResourceUris");
|
||||
if (monitored_resource_uris == NULL) {
|
||||
if (!exposure_data_subscription->monitored_resource_uris) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *monitored_resource_urisList = cJSON_AddArrayToObject(item, "monitoredResourceUris");
|
||||
if (monitored_resource_urisList == NULL) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *monitored_resource_uris_node;
|
||||
OpenAPI_list_for_each(exposure_data_subscription->monitored_resource_uris, monitored_resource_uris_node) {
|
||||
if (cJSON_AddStringToObject(monitored_resource_uris, "", (char*)monitored_resource_uris_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
OpenAPI_list_for_each(exposure_data_subscription->monitored_resource_uris, node) {
|
||||
if (cJSON_AddStringToObject(monitored_resource_urisList, "", (char*)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_convertToJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exposure_data_subscription->expiry) {
|
||||
if (cJSON_AddStringToObject(item, "expiry", exposure_data_subscription->expiry) == NULL) {
|
||||
|
|
@ -88,52 +108,56 @@ end:
|
|||
OpenAPI_exposure_data_subscription_t *OpenAPI_exposure_data_subscription_parseFromJSON(cJSON *exposure_data_subscriptionJSON)
|
||||
{
|
||||
OpenAPI_exposure_data_subscription_t *exposure_data_subscription_local_var = NULL;
|
||||
cJSON *notification_uri = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "notificationUri");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *notification_uri = NULL;
|
||||
cJSON *monitored_resource_uris = NULL;
|
||||
OpenAPI_list_t *monitored_resource_urisList = NULL;
|
||||
cJSON *expiry = NULL;
|
||||
cJSON *supported_features = NULL;
|
||||
notification_uri = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "notificationUri");
|
||||
if (!notification_uri) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [notification_uri]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(notification_uri)) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [notification_uri]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *monitored_resource_uris = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "monitoredResourceUris");
|
||||
monitored_resource_uris = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "monitoredResourceUris");
|
||||
if (!monitored_resource_uris) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
cJSON *monitored_resource_uris_local = NULL;
|
||||
if (!cJSON_IsArray(monitored_resource_uris)) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_t *monitored_resource_urisList;
|
||||
cJSON *monitored_resource_uris_local;
|
||||
if (!cJSON_IsArray(monitored_resource_uris)) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
monitored_resource_urisList = OpenAPI_list_create();
|
||||
monitored_resource_urisList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(monitored_resource_uris_local, monitored_resource_uris) {
|
||||
if (!cJSON_IsString(monitored_resource_uris_local)) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(monitored_resource_urisList, ogs_strdup(monitored_resource_uris_local->valuestring));
|
||||
}
|
||||
|
||||
cJSON *expiry = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "expiry");
|
||||
cJSON_ArrayForEach(monitored_resource_uris_local, monitored_resource_uris) {
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
if (!cJSON_IsString(monitored_resource_uris_local)) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [monitored_resource_uris]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(monitored_resource_urisList, ogs_strdup(monitored_resource_uris_local->valuestring));
|
||||
}
|
||||
|
||||
expiry = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "expiry");
|
||||
if (expiry) {
|
||||
if (!cJSON_IsString(expiry)) {
|
||||
if (!cJSON_IsString(expiry) && !cJSON_IsNull(expiry)) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [expiry]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *supported_features = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "supportedFeatures");
|
||||
|
||||
supported_features = cJSON_GetObjectItemCaseSensitive(exposure_data_subscriptionJSON, "supportedFeatures");
|
||||
if (supported_features) {
|
||||
if (!cJSON_IsString(supported_features)) {
|
||||
if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) {
|
||||
ogs_error("OpenAPI_exposure_data_subscription_parseFromJSON() failed [supported_features]");
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -142,12 +166,19 @@ OpenAPI_exposure_data_subscription_t *OpenAPI_exposure_data_subscription_parseFr
|
|||
exposure_data_subscription_local_var = OpenAPI_exposure_data_subscription_create (
|
||||
ogs_strdup(notification_uri->valuestring),
|
||||
monitored_resource_urisList,
|
||||
expiry ? ogs_strdup(expiry->valuestring) : NULL,
|
||||
supported_features ? ogs_strdup(supported_features->valuestring) : NULL
|
||||
expiry && !cJSON_IsNull(expiry) ? ogs_strdup(expiry->valuestring) : NULL,
|
||||
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL
|
||||
);
|
||||
|
||||
return exposure_data_subscription_local_var;
|
||||
end:
|
||||
if (monitored_resource_urisList) {
|
||||
OpenAPI_list_for_each(monitored_resource_urisList, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(monitored_resource_urisList);
|
||||
monitored_resource_urisList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue