[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_requested_rule_data_t *OpenAPI_requested_rule_data_create(
void OpenAPI_requested_rule_data_free(OpenAPI_requested_rule_data_t *requested_rule_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == requested_rule_data) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_list_for_each(requested_rule_data->ref_pcc_rule_ids, node) {
ogs_free(node->data);
if (requested_rule_data->ref_pcc_rule_ids) {
OpenAPI_list_for_each(requested_rule_data->ref_pcc_rule_ids, node) {
ogs_free(node->data);
}
OpenAPI_list_free(requested_rule_data->ref_pcc_rule_ids);
requested_rule_data->ref_pcc_rule_ids = NULL;
}
if (requested_rule_data->req_data) {
OpenAPI_list_free(requested_rule_data->req_data);
requested_rule_data->req_data = NULL;
}
OpenAPI_list_free(requested_rule_data->ref_pcc_rule_ids);
OpenAPI_list_free(requested_rule_data->req_data);
ogs_free(requested_rule_data);
}
cJSON *OpenAPI_requested_rule_data_convertToJSON(OpenAPI_requested_rule_data_t *requested_rule_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (requested_rule_data == NULL) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [RequestedRuleData]");
@ -42,28 +50,33 @@ cJSON *OpenAPI_requested_rule_data_convertToJSON(OpenAPI_requested_rule_data_t *
}
item = cJSON_CreateObject();
cJSON *ref_pcc_rule_ids = cJSON_AddArrayToObject(item, "refPccRuleIds");
if (ref_pcc_rule_ids == NULL) {
if (!requested_rule_data->ref_pcc_rule_ids) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [ref_pcc_rule_ids]");
return NULL;
}
cJSON *ref_pcc_rule_idsList = cJSON_AddArrayToObject(item, "refPccRuleIds");
if (ref_pcc_rule_idsList == NULL) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [ref_pcc_rule_ids]");
goto end;
}
OpenAPI_lnode_t *ref_pcc_rule_ids_node;
OpenAPI_list_for_each(requested_rule_data->ref_pcc_rule_ids, ref_pcc_rule_ids_node) {
if (cJSON_AddStringToObject(ref_pcc_rule_ids, "", (char*)ref_pcc_rule_ids_node->data) == NULL) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [ref_pcc_rule_ids]");
goto end;
OpenAPI_list_for_each(requested_rule_data->ref_pcc_rule_ids, node) {
if (cJSON_AddStringToObject(ref_pcc_rule_idsList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [ref_pcc_rule_ids]");
goto end;
}
}
}
cJSON *req_data = cJSON_AddArrayToObject(item, "reqData");
if (req_data == NULL) {
if (requested_rule_data->req_data == OpenAPI_requested_rule_data_type_NULL) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [req_data]");
return NULL;
}
cJSON *req_dataList = cJSON_AddArrayToObject(item, "reqData");
if (req_dataList == NULL) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [req_data]");
goto end;
}
OpenAPI_lnode_t *req_data_node;
OpenAPI_list_for_each(requested_rule_data->req_data, req_data_node) {
if (cJSON_AddStringToObject(req_data, "", OpenAPI_requested_rule_data_type_ToString((intptr_t)req_data_node->data)) == NULL) {
OpenAPI_list_for_each(requested_rule_data->req_data, node) {
if (cJSON_AddStringToObject(req_dataList, "", OpenAPI_requested_rule_data_type_ToString((intptr_t)node->data)) == NULL) {
ogs_error("OpenAPI_requested_rule_data_convertToJSON() failed [req_data]");
goto end;
}
@ -76,51 +89,54 @@ end:
OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_parseFromJSON(cJSON *requested_rule_dataJSON)
{
OpenAPI_requested_rule_data_t *requested_rule_data_local_var = NULL;
cJSON *ref_pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(requested_rule_dataJSON, "refPccRuleIds");
OpenAPI_lnode_t *node = NULL;
cJSON *ref_pcc_rule_ids = NULL;
OpenAPI_list_t *ref_pcc_rule_idsList = NULL;
cJSON *req_data = NULL;
OpenAPI_list_t *req_dataList = NULL;
ref_pcc_rule_ids = cJSON_GetObjectItemCaseSensitive(requested_rule_dataJSON, "refPccRuleIds");
if (!ref_pcc_rule_ids) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]");
goto end;
}
cJSON *ref_pcc_rule_ids_local = NULL;
if (!cJSON_IsArray(ref_pcc_rule_ids)) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]");
goto end;
}
OpenAPI_list_t *ref_pcc_rule_idsList;
cJSON *ref_pcc_rule_ids_local;
if (!cJSON_IsArray(ref_pcc_rule_ids)) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]");
goto end;
}
ref_pcc_rule_idsList = OpenAPI_list_create();
ref_pcc_rule_idsList = OpenAPI_list_create();
cJSON_ArrayForEach(ref_pcc_rule_ids_local, ref_pcc_rule_ids) {
if (!cJSON_IsString(ref_pcc_rule_ids_local)) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]");
goto end;
}
OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup(ref_pcc_rule_ids_local->valuestring));
}
cJSON_ArrayForEach(ref_pcc_rule_ids_local, ref_pcc_rule_ids) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(ref_pcc_rule_ids_local)) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [ref_pcc_rule_ids]");
goto end;
}
OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup(ref_pcc_rule_ids_local->valuestring));
}
cJSON *req_data = cJSON_GetObjectItemCaseSensitive(requested_rule_dataJSON, "reqData");
req_data = cJSON_GetObjectItemCaseSensitive(requested_rule_dataJSON, "reqData");
if (!req_data) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [req_data]");
goto end;
}
OpenAPI_list_t *req_dataList;
cJSON *req_data_local_nonprimitive;
if (!cJSON_IsArray(req_data)) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [req_data]");
goto end;
}
req_dataList = OpenAPI_list_create();
cJSON_ArrayForEach(req_data_local_nonprimitive, req_data ) {
if (!cJSON_IsString(req_data_local_nonprimitive)){
cJSON *req_data_local = NULL;
if (!cJSON_IsArray(req_data)) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [req_data]");
goto end;
}
OpenAPI_list_add(req_dataList, (void *)OpenAPI_requested_rule_data_type_FromString(req_data_local_nonprimitive->valuestring));
}
req_dataList = OpenAPI_list_create();
cJSON_ArrayForEach(req_data_local, req_data) {
if (!cJSON_IsString(req_data_local)) {
ogs_error("OpenAPI_requested_rule_data_parseFromJSON() failed [req_data]");
goto end;
}
OpenAPI_list_add(req_dataList, (void *)OpenAPI_requested_rule_data_type_FromString(req_data_local->valuestring));
}
requested_rule_data_local_var = OpenAPI_requested_rule_data_create (
ref_pcc_rule_idsList,
@ -129,6 +145,17 @@ OpenAPI_requested_rule_data_t *OpenAPI_requested_rule_data_parseFromJSON(cJSON *
return requested_rule_data_local_var;
end:
if (ref_pcc_rule_idsList) {
OpenAPI_list_for_each(ref_pcc_rule_idsList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(ref_pcc_rule_idsList);
ref_pcc_rule_idsList = NULL;
}
if (req_dataList) {
OpenAPI_list_free(req_dataList);
req_dataList = NULL;
}
return NULL;
}