[SBI] Crash occurs when ENUM in the MAP (#2103)

This commit is contained in:
Sukchan Lee 2023-03-01 17:50:25 +09:00
parent ce668c556c
commit 969c116e77
1097 changed files with 266728 additions and 42047 deletions

View file

@ -20,21 +20,29 @@ OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_create(
void OpenAPI_candidate_for_replacement_free(OpenAPI_candidate_for_replacement_t *candidate_for_replacement)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == candidate_for_replacement) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_snssai_free(candidate_for_replacement->snssai);
OpenAPI_list_for_each(candidate_for_replacement->dnns, node) {
ogs_free(node->data);
if (candidate_for_replacement->snssai) {
OpenAPI_snssai_free(candidate_for_replacement->snssai);
candidate_for_replacement->snssai = NULL;
}
if (candidate_for_replacement->dnns) {
OpenAPI_list_for_each(candidate_for_replacement->dnns, node) {
ogs_free(node->data);
}
OpenAPI_list_free(candidate_for_replacement->dnns);
candidate_for_replacement->dnns = NULL;
}
OpenAPI_list_free(candidate_for_replacement->dnns);
ogs_free(candidate_for_replacement);
}
cJSON *OpenAPI_candidate_for_replacement_convertToJSON(OpenAPI_candidate_for_replacement_t *candidate_for_replacement)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (candidate_for_replacement == NULL) {
ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [CandidateForReplacement]");
@ -42,6 +50,10 @@ cJSON *OpenAPI_candidate_for_replacement_convertToJSON(OpenAPI_candidate_for_rep
}
item = cJSON_CreateObject();
if (!candidate_for_replacement->snssai) {
ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [snssai]");
return NULL;
}
cJSON *snssai_local_JSON = OpenAPI_snssai_convertToJSON(candidate_for_replacement->snssai);
if (snssai_local_JSON == NULL) {
ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [snssai]");
@ -54,19 +66,17 @@ cJSON *OpenAPI_candidate_for_replacement_convertToJSON(OpenAPI_candidate_for_rep
}
if (candidate_for_replacement->dnns) {
cJSON *dnns = cJSON_AddArrayToObject(item, "dnns");
if (dnns == NULL) {
cJSON *dnnsList = cJSON_AddArrayToObject(item, "dnns");
if (dnnsList == NULL) {
ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [dnns]");
goto end;
}
OpenAPI_lnode_t *dnns_node;
OpenAPI_list_for_each(candidate_for_replacement->dnns, dnns_node) {
if (cJSON_AddStringToObject(dnns, "", (char*)dnns_node->data) == NULL) {
ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [dnns]");
goto end;
OpenAPI_list_for_each(candidate_for_replacement->dnns, node) {
if (cJSON_AddStringToObject(dnnsList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_candidate_for_replacement_convertToJSON() failed [dnns]");
goto end;
}
}
}
}
end:
@ -76,33 +86,37 @@ end:
OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_parseFromJSON(cJSON *candidate_for_replacementJSON)
{
OpenAPI_candidate_for_replacement_t *candidate_for_replacement_local_var = NULL;
cJSON *snssai = cJSON_GetObjectItemCaseSensitive(candidate_for_replacementJSON, "snssai");
OpenAPI_lnode_t *node = NULL;
cJSON *snssai = NULL;
OpenAPI_snssai_t *snssai_local_nonprim = NULL;
cJSON *dnns = NULL;
OpenAPI_list_t *dnnsList = NULL;
snssai = cJSON_GetObjectItemCaseSensitive(candidate_for_replacementJSON, "snssai");
if (!snssai) {
ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [snssai]");
goto end;
}
OpenAPI_snssai_t *snssai_local_nonprim = NULL;
snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(snssai);
cJSON *dnns = cJSON_GetObjectItemCaseSensitive(candidate_for_replacementJSON, "dnns");
OpenAPI_list_t *dnnsList;
dnns = cJSON_GetObjectItemCaseSensitive(candidate_for_replacementJSON, "dnns");
if (dnns) {
cJSON *dnns_local;
if (!cJSON_IsArray(dnns)) {
ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [dnns]");
goto end;
}
dnnsList = OpenAPI_list_create();
cJSON *dnns_local = NULL;
if (!cJSON_IsArray(dnns)) {
ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [dnns]");
goto end;
}
cJSON_ArrayForEach(dnns_local, dnns) {
if (!cJSON_IsString(dnns_local)) {
ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [dnns]");
goto end;
}
OpenAPI_list_add(dnnsList, ogs_strdup(dnns_local->valuestring));
}
dnnsList = OpenAPI_list_create();
cJSON_ArrayForEach(dnns_local, dnns) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(dnns_local)) {
ogs_error("OpenAPI_candidate_for_replacement_parseFromJSON() failed [dnns]");
goto end;
}
OpenAPI_list_add(dnnsList, ogs_strdup(dnns_local->valuestring));
}
}
candidate_for_replacement_local_var = OpenAPI_candidate_for_replacement_create (
@ -112,6 +126,17 @@ OpenAPI_candidate_for_replacement_t *OpenAPI_candidate_for_replacement_parseFrom
return candidate_for_replacement_local_var;
end:
if (snssai_local_nonprim) {
OpenAPI_snssai_free(snssai_local_nonprim);
snssai_local_nonprim = NULL;
}
if (dnnsList) {
OpenAPI_list_for_each(dnnsList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(dnnsList);
dnnsList = NULL;
}
return NULL;
}