mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-02 13:20: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
|
|
@ -22,24 +22,32 @@ OpenAPI_flows_t *OpenAPI_flows_create(
|
|||
|
||||
void OpenAPI_flows_free(OpenAPI_flows_t *flows)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == flows) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_list_for_each(flows->cont_vers, node) {
|
||||
ogs_free(node->data);
|
||||
if (flows->cont_vers) {
|
||||
OpenAPI_list_for_each(flows->cont_vers, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(flows->cont_vers);
|
||||
flows->cont_vers = NULL;
|
||||
}
|
||||
OpenAPI_list_free(flows->cont_vers);
|
||||
OpenAPI_list_for_each(flows->f_nums, node) {
|
||||
ogs_free(node->data);
|
||||
if (flows->f_nums) {
|
||||
OpenAPI_list_for_each(flows->f_nums, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(flows->f_nums);
|
||||
flows->f_nums = NULL;
|
||||
}
|
||||
OpenAPI_list_free(flows->f_nums);
|
||||
ogs_free(flows);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_flows_convertToJSON(OpenAPI_flows_t *flows)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (flows == NULL) {
|
||||
ogs_error("OpenAPI_flows_convertToJSON() failed [Flows]");
|
||||
|
|
@ -48,35 +56,31 @@ cJSON *OpenAPI_flows_convertToJSON(OpenAPI_flows_t *flows)
|
|||
|
||||
item = cJSON_CreateObject();
|
||||
if (flows->cont_vers) {
|
||||
cJSON *cont_vers = cJSON_AddArrayToObject(item, "contVers");
|
||||
if (cont_vers == NULL) {
|
||||
cJSON *cont_versList = cJSON_AddArrayToObject(item, "contVers");
|
||||
if (cont_versList == NULL) {
|
||||
ogs_error("OpenAPI_flows_convertToJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *cont_vers_node;
|
||||
OpenAPI_list_for_each(flows->cont_vers, cont_vers_node) {
|
||||
if (cJSON_AddNumberToObject(cont_vers, "", *(double *)cont_vers_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_flows_convertToJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
OpenAPI_list_for_each(flows->cont_vers, node) {
|
||||
if (cJSON_AddNumberToObject(cont_versList, "", (uintptr_t)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_flows_convertToJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flows->f_nums) {
|
||||
cJSON *f_nums = cJSON_AddArrayToObject(item, "fNums");
|
||||
if (f_nums == NULL) {
|
||||
cJSON *f_numsList = cJSON_AddArrayToObject(item, "fNums");
|
||||
if (f_numsList == NULL) {
|
||||
ogs_error("OpenAPI_flows_convertToJSON() failed [f_nums]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *f_nums_node;
|
||||
OpenAPI_list_for_each(flows->f_nums, f_nums_node) {
|
||||
if (cJSON_AddNumberToObject(f_nums, "", *(double *)f_nums_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_flows_convertToJSON() failed [f_nums]");
|
||||
goto end;
|
||||
OpenAPI_list_for_each(flows->f_nums, node) {
|
||||
if (cJSON_AddNumberToObject(f_numsList, "", (uintptr_t)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_flows_convertToJSON() failed [f_nums]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cJSON_AddNumberToObject(item, "medCompN", flows->med_comp_n) == NULL) {
|
||||
|
|
@ -91,52 +95,71 @@ end:
|
|||
OpenAPI_flows_t *OpenAPI_flows_parseFromJSON(cJSON *flowsJSON)
|
||||
{
|
||||
OpenAPI_flows_t *flows_local_var = NULL;
|
||||
cJSON *cont_vers = cJSON_GetObjectItemCaseSensitive(flowsJSON, "contVers");
|
||||
|
||||
OpenAPI_list_t *cont_versList;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *cont_vers = NULL;
|
||||
OpenAPI_list_t *cont_versList = NULL;
|
||||
cJSON *f_nums = NULL;
|
||||
OpenAPI_list_t *f_numsList = NULL;
|
||||
cJSON *med_comp_n = NULL;
|
||||
cont_vers = cJSON_GetObjectItemCaseSensitive(flowsJSON, "contVers");
|
||||
if (cont_vers) {
|
||||
cJSON *cont_vers_local;
|
||||
if (!cJSON_IsArray(cont_vers)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
}
|
||||
cont_versList = OpenAPI_list_create();
|
||||
cJSON *cont_vers_local = NULL;
|
||||
if (!cJSON_IsArray(cont_vers)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON_ArrayForEach(cont_vers_local, cont_vers) {
|
||||
if (!cJSON_IsNumber(cont_vers_local)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(cont_versList, &cont_vers_local->valuedouble);
|
||||
}
|
||||
cont_versList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(cont_vers_local, cont_vers) {
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
if (!cJSON_IsNumber(cont_vers_local)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
}
|
||||
localDouble = (double *)ogs_calloc(1, sizeof(double));
|
||||
if (!localDouble) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [cont_vers]");
|
||||
goto end;
|
||||
}
|
||||
*localDouble = cont_vers_local->valuedouble;
|
||||
OpenAPI_list_add(cont_versList, localDouble);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *f_nums = cJSON_GetObjectItemCaseSensitive(flowsJSON, "fNums");
|
||||
|
||||
OpenAPI_list_t *f_numsList;
|
||||
f_nums = cJSON_GetObjectItemCaseSensitive(flowsJSON, "fNums");
|
||||
if (f_nums) {
|
||||
cJSON *f_nums_local;
|
||||
if (!cJSON_IsArray(f_nums)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [f_nums]");
|
||||
goto end;
|
||||
}
|
||||
f_numsList = OpenAPI_list_create();
|
||||
cJSON *f_nums_local = NULL;
|
||||
if (!cJSON_IsArray(f_nums)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [f_nums]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON_ArrayForEach(f_nums_local, f_nums) {
|
||||
if (!cJSON_IsNumber(f_nums_local)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [f_nums]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(f_numsList, &f_nums_local->valuedouble);
|
||||
}
|
||||
f_numsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(f_nums_local, f_nums) {
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
if (!cJSON_IsNumber(f_nums_local)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [f_nums]");
|
||||
goto end;
|
||||
}
|
||||
localDouble = (double *)ogs_calloc(1, sizeof(double));
|
||||
if (!localDouble) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [f_nums]");
|
||||
goto end;
|
||||
}
|
||||
*localDouble = f_nums_local->valuedouble;
|
||||
OpenAPI_list_add(f_numsList, localDouble);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *med_comp_n = cJSON_GetObjectItemCaseSensitive(flowsJSON, "medCompN");
|
||||
med_comp_n = cJSON_GetObjectItemCaseSensitive(flowsJSON, "medCompN");
|
||||
if (!med_comp_n) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [med_comp_n]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsNumber(med_comp_n)) {
|
||||
ogs_error("OpenAPI_flows_parseFromJSON() failed [med_comp_n]");
|
||||
goto end;
|
||||
|
|
@ -151,6 +174,20 @@ OpenAPI_flows_t *OpenAPI_flows_parseFromJSON(cJSON *flowsJSON)
|
|||
|
||||
return flows_local_var;
|
||||
end:
|
||||
if (cont_versList) {
|
||||
OpenAPI_list_for_each(cont_versList, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(cont_versList);
|
||||
cont_versList = NULL;
|
||||
}
|
||||
if (f_numsList) {
|
||||
OpenAPI_list_for_each(f_numsList, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(f_numsList);
|
||||
f_numsList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue