mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 14:20: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,20 +20,25 @@ OpenAPI_smf_change_info_t *OpenAPI_smf_change_info_create(
|
|||
|
||||
void OpenAPI_smf_change_info_free(OpenAPI_smf_change_info_t *smf_change_info)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == smf_change_info) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_list_for_each(smf_change_info->pdu_session_id_list, node) {
|
||||
ogs_free(node->data);
|
||||
if (smf_change_info->pdu_session_id_list) {
|
||||
OpenAPI_list_for_each(smf_change_info->pdu_session_id_list, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(smf_change_info->pdu_session_id_list);
|
||||
smf_change_info->pdu_session_id_list = NULL;
|
||||
}
|
||||
OpenAPI_list_free(smf_change_info->pdu_session_id_list);
|
||||
ogs_free(smf_change_info);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_smf_change_info_convertToJSON(OpenAPI_smf_change_info_t *smf_change_info)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (smf_change_info == NULL) {
|
||||
ogs_error("OpenAPI_smf_change_info_convertToJSON() failed [SmfChangeInfo]");
|
||||
|
|
@ -41,20 +46,26 @@ cJSON *OpenAPI_smf_change_info_convertToJSON(OpenAPI_smf_change_info_t *smf_chan
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
cJSON *pdu_session_id_list = cJSON_AddArrayToObject(item, "pduSessionIdList");
|
||||
if (pdu_session_id_list == NULL) {
|
||||
if (!smf_change_info->pdu_session_id_list) {
|
||||
ogs_error("OpenAPI_smf_change_info_convertToJSON() failed [pdu_session_id_list]");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *pdu_session_id_listList = cJSON_AddArrayToObject(item, "pduSessionIdList");
|
||||
if (pdu_session_id_listList == NULL) {
|
||||
ogs_error("OpenAPI_smf_change_info_convertToJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *pdu_session_id_list_node;
|
||||
OpenAPI_list_for_each(smf_change_info->pdu_session_id_list, pdu_session_id_list_node) {
|
||||
if (cJSON_AddNumberToObject(pdu_session_id_list, "", *(double *)pdu_session_id_list_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_smf_change_info_convertToJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
OpenAPI_list_for_each(smf_change_info->pdu_session_id_list, node) {
|
||||
if (cJSON_AddNumberToObject(pdu_session_id_listList, "", (uintptr_t)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_smf_change_info_convertToJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (smf_change_info->smf_change_ind == OpenAPI_smf_change_indication_NULL) {
|
||||
ogs_error("OpenAPI_smf_change_info_convertToJSON() failed [smf_change_ind]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "smfChangeInd", OpenAPI_smf_change_indication_ToString(smf_change_info->smf_change_ind)) == NULL) {
|
||||
ogs_error("OpenAPI_smf_change_info_convertToJSON() failed [smf_change_ind]");
|
||||
goto end;
|
||||
|
|
@ -67,35 +78,45 @@ end:
|
|||
OpenAPI_smf_change_info_t *OpenAPI_smf_change_info_parseFromJSON(cJSON *smf_change_infoJSON)
|
||||
{
|
||||
OpenAPI_smf_change_info_t *smf_change_info_local_var = NULL;
|
||||
cJSON *pdu_session_id_list = cJSON_GetObjectItemCaseSensitive(smf_change_infoJSON, "pduSessionIdList");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *pdu_session_id_list = NULL;
|
||||
OpenAPI_list_t *pdu_session_id_listList = NULL;
|
||||
cJSON *smf_change_ind = NULL;
|
||||
OpenAPI_smf_change_indication_e smf_change_indVariable = 0;
|
||||
pdu_session_id_list = cJSON_GetObjectItemCaseSensitive(smf_change_infoJSON, "pduSessionIdList");
|
||||
if (!pdu_session_id_list) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
cJSON *pdu_session_id_list_local = NULL;
|
||||
if (!cJSON_IsArray(pdu_session_id_list)) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_t *pdu_session_id_listList;
|
||||
cJSON *pdu_session_id_list_local;
|
||||
if (!cJSON_IsArray(pdu_session_id_list)) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
pdu_session_id_listList = OpenAPI_list_create();
|
||||
pdu_session_id_listList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(pdu_session_id_list_local, pdu_session_id_list) {
|
||||
if (!cJSON_IsNumber(pdu_session_id_list_local)) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(pdu_session_id_listList, &pdu_session_id_list_local->valuedouble);
|
||||
}
|
||||
cJSON_ArrayForEach(pdu_session_id_list_local, pdu_session_id_list) {
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
if (!cJSON_IsNumber(pdu_session_id_list_local)) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
localDouble = (double *)ogs_calloc(1, sizeof(double));
|
||||
if (!localDouble) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [pdu_session_id_list]");
|
||||
goto end;
|
||||
}
|
||||
*localDouble = pdu_session_id_list_local->valuedouble;
|
||||
OpenAPI_list_add(pdu_session_id_listList, localDouble);
|
||||
}
|
||||
|
||||
cJSON *smf_change_ind = cJSON_GetObjectItemCaseSensitive(smf_change_infoJSON, "smfChangeInd");
|
||||
smf_change_ind = cJSON_GetObjectItemCaseSensitive(smf_change_infoJSON, "smfChangeInd");
|
||||
if (!smf_change_ind) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [smf_change_ind]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_smf_change_indication_e smf_change_indVariable;
|
||||
if (!cJSON_IsString(smf_change_ind)) {
|
||||
ogs_error("OpenAPI_smf_change_info_parseFromJSON() failed [smf_change_ind]");
|
||||
goto end;
|
||||
|
|
@ -109,6 +130,13 @@ OpenAPI_smf_change_info_t *OpenAPI_smf_change_info_parseFromJSON(cJSON *smf_chan
|
|||
|
||||
return smf_change_info_local_var;
|
||||
end:
|
||||
if (pdu_session_id_listList) {
|
||||
OpenAPI_list_for_each(pdu_session_id_listList, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(pdu_session_id_listList);
|
||||
pdu_session_id_listList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue