[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

@ -22,22 +22,33 @@ OpenAPI_scheduled_communication_time_t *OpenAPI_scheduled_communication_time_cre
void OpenAPI_scheduled_communication_time_free(OpenAPI_scheduled_communication_time_t *scheduled_communication_time)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == scheduled_communication_time) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_list_for_each(scheduled_communication_time->days_of_week, node) {
ogs_free(node->data);
if (scheduled_communication_time->days_of_week) {
OpenAPI_list_for_each(scheduled_communication_time->days_of_week, node) {
ogs_free(node->data);
}
OpenAPI_list_free(scheduled_communication_time->days_of_week);
scheduled_communication_time->days_of_week = NULL;
}
if (scheduled_communication_time->time_of_day_start) {
ogs_free(scheduled_communication_time->time_of_day_start);
scheduled_communication_time->time_of_day_start = NULL;
}
if (scheduled_communication_time->time_of_day_end) {
ogs_free(scheduled_communication_time->time_of_day_end);
scheduled_communication_time->time_of_day_end = NULL;
}
OpenAPI_list_free(scheduled_communication_time->days_of_week);
ogs_free(scheduled_communication_time->time_of_day_start);
ogs_free(scheduled_communication_time->time_of_day_end);
ogs_free(scheduled_communication_time);
}
cJSON *OpenAPI_scheduled_communication_time_convertToJSON(OpenAPI_scheduled_communication_time_t *scheduled_communication_time)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (scheduled_communication_time == NULL) {
ogs_error("OpenAPI_scheduled_communication_time_convertToJSON() failed [ScheduledCommunicationTime]");
@ -46,19 +57,17 @@ cJSON *OpenAPI_scheduled_communication_time_convertToJSON(OpenAPI_scheduled_comm
item = cJSON_CreateObject();
if (scheduled_communication_time->days_of_week) {
cJSON *days_of_week = cJSON_AddArrayToObject(item, "daysOfWeek");
if (days_of_week == NULL) {
cJSON *days_of_weekList = cJSON_AddArrayToObject(item, "daysOfWeek");
if (days_of_weekList == NULL) {
ogs_error("OpenAPI_scheduled_communication_time_convertToJSON() failed [days_of_week]");
goto end;
}
OpenAPI_lnode_t *days_of_week_node;
OpenAPI_list_for_each(scheduled_communication_time->days_of_week, days_of_week_node) {
if (cJSON_AddNumberToObject(days_of_week, "", *(double *)days_of_week_node->data) == NULL) {
ogs_error("OpenAPI_scheduled_communication_time_convertToJSON() failed [days_of_week]");
goto end;
OpenAPI_list_for_each(scheduled_communication_time->days_of_week, node) {
if (cJSON_AddNumberToObject(days_of_weekList, "", (uintptr_t)node->data) == NULL) {
ogs_error("OpenAPI_scheduled_communication_time_convertToJSON() failed [days_of_week]");
goto end;
}
}
}
}
if (scheduled_communication_time->time_of_day_start) {
@ -82,39 +91,49 @@ end:
OpenAPI_scheduled_communication_time_t *OpenAPI_scheduled_communication_time_parseFromJSON(cJSON *scheduled_communication_timeJSON)
{
OpenAPI_scheduled_communication_time_t *scheduled_communication_time_local_var = NULL;
cJSON *days_of_week = cJSON_GetObjectItemCaseSensitive(scheduled_communication_timeJSON, "daysOfWeek");
OpenAPI_list_t *days_of_weekList;
OpenAPI_lnode_t *node = NULL;
cJSON *days_of_week = NULL;
OpenAPI_list_t *days_of_weekList = NULL;
cJSON *time_of_day_start = NULL;
cJSON *time_of_day_end = NULL;
days_of_week = cJSON_GetObjectItemCaseSensitive(scheduled_communication_timeJSON, "daysOfWeek");
if (days_of_week) {
cJSON *days_of_week_local;
if (!cJSON_IsArray(days_of_week)) {
ogs_error("OpenAPI_scheduled_communication_time_parseFromJSON() failed [days_of_week]");
goto end;
}
days_of_weekList = OpenAPI_list_create();
cJSON *days_of_week_local = NULL;
if (!cJSON_IsArray(days_of_week)) {
ogs_error("OpenAPI_scheduled_communication_time_parseFromJSON() failed [days_of_week]");
goto end;
}
cJSON_ArrayForEach(days_of_week_local, days_of_week) {
if (!cJSON_IsNumber(days_of_week_local)) {
ogs_error("OpenAPI_scheduled_communication_time_parseFromJSON() failed [days_of_week]");
goto end;
}
OpenAPI_list_add(days_of_weekList, &days_of_week_local->valuedouble);
}
days_of_weekList = OpenAPI_list_create();
cJSON_ArrayForEach(days_of_week_local, days_of_week) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsNumber(days_of_week_local)) {
ogs_error("OpenAPI_scheduled_communication_time_parseFromJSON() failed [days_of_week]");
goto end;
}
localDouble = (double *)ogs_calloc(1, sizeof(double));
if (!localDouble) {
ogs_error("OpenAPI_scheduled_communication_time_parseFromJSON() failed [days_of_week]");
goto end;
}
*localDouble = days_of_week_local->valuedouble;
OpenAPI_list_add(days_of_weekList, localDouble);
}
}
cJSON *time_of_day_start = cJSON_GetObjectItemCaseSensitive(scheduled_communication_timeJSON, "timeOfDayStart");
time_of_day_start = cJSON_GetObjectItemCaseSensitive(scheduled_communication_timeJSON, "timeOfDayStart");
if (time_of_day_start) {
if (!cJSON_IsString(time_of_day_start)) {
if (!cJSON_IsString(time_of_day_start) && !cJSON_IsNull(time_of_day_start)) {
ogs_error("OpenAPI_scheduled_communication_time_parseFromJSON() failed [time_of_day_start]");
goto end;
}
}
cJSON *time_of_day_end = cJSON_GetObjectItemCaseSensitive(scheduled_communication_timeJSON, "timeOfDayEnd");
time_of_day_end = cJSON_GetObjectItemCaseSensitive(scheduled_communication_timeJSON, "timeOfDayEnd");
if (time_of_day_end) {
if (!cJSON_IsString(time_of_day_end)) {
if (!cJSON_IsString(time_of_day_end) && !cJSON_IsNull(time_of_day_end)) {
ogs_error("OpenAPI_scheduled_communication_time_parseFromJSON() failed [time_of_day_end]");
goto end;
}
@ -122,12 +141,19 @@ OpenAPI_scheduled_communication_time_t *OpenAPI_scheduled_communication_time_par
scheduled_communication_time_local_var = OpenAPI_scheduled_communication_time_create (
days_of_week ? days_of_weekList : NULL,
time_of_day_start ? ogs_strdup(time_of_day_start->valuestring) : NULL,
time_of_day_end ? ogs_strdup(time_of_day_end->valuestring) : NULL
time_of_day_start && !cJSON_IsNull(time_of_day_start) ? ogs_strdup(time_of_day_start->valuestring) : NULL,
time_of_day_end && !cJSON_IsNull(time_of_day_end) ? ogs_strdup(time_of_day_end->valuestring) : NULL
);
return scheduled_communication_time_local_var;
end:
if (days_of_weekList) {
OpenAPI_list_for_each(days_of_weekList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(days_of_weekList);
days_of_weekList = NULL;
}
return NULL;
}