[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,17 +22,22 @@ OpenAPI_time_period_t *OpenAPI_time_period_create(
void OpenAPI_time_period_free(OpenAPI_time_period_t *time_period)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == time_period) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_periodicity_free(time_period->period);
if (time_period->period) {
OpenAPI_periodicity_free(time_period->period);
time_period->period = NULL;
}
ogs_free(time_period);
}
cJSON *OpenAPI_time_period_convertToJSON(OpenAPI_time_period_t *time_period)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (time_period == NULL) {
ogs_error("OpenAPI_time_period_convertToJSON() failed [TimePeriod]");
@ -40,6 +45,10 @@ cJSON *OpenAPI_time_period_convertToJSON(OpenAPI_time_period_t *time_period)
}
item = cJSON_CreateObject();
if (!time_period->period) {
ogs_error("OpenAPI_time_period_convertToJSON() failed [period]");
return NULL;
}
cJSON *period_local_JSON = OpenAPI_periodicity_convertToJSON(time_period->period);
if (period_local_JSON == NULL) {
ogs_error("OpenAPI_time_period_convertToJSON() failed [period]");
@ -65,17 +74,18 @@ end:
OpenAPI_time_period_t *OpenAPI_time_period_parseFromJSON(cJSON *time_periodJSON)
{
OpenAPI_time_period_t *time_period_local_var = NULL;
cJSON *period = cJSON_GetObjectItemCaseSensitive(time_periodJSON, "period");
OpenAPI_lnode_t *node = NULL;
cJSON *period = NULL;
OpenAPI_periodicity_t *period_local_nonprim = NULL;
cJSON *max_num_period = NULL;
period = cJSON_GetObjectItemCaseSensitive(time_periodJSON, "period");
if (!period) {
ogs_error("OpenAPI_time_period_parseFromJSON() failed [period]");
goto end;
}
OpenAPI_periodicity_t *period_local_nonprim = NULL;
period_local_nonprim = OpenAPI_periodicity_parseFromJSON(period);
cJSON *max_num_period = cJSON_GetObjectItemCaseSensitive(time_periodJSON, "maxNumPeriod");
max_num_period = cJSON_GetObjectItemCaseSensitive(time_periodJSON, "maxNumPeriod");
if (max_num_period) {
if (!cJSON_IsNumber(max_num_period)) {
ogs_error("OpenAPI_time_period_parseFromJSON() failed [max_num_period]");
@ -91,6 +101,10 @@ OpenAPI_time_period_t *OpenAPI_time_period_parseFromJSON(cJSON *time_periodJSON)
return time_period_local_var;
end:
if (period_local_nonprim) {
OpenAPI_periodicity_free(period_local_nonprim);
period_local_nonprim = NULL;
}
return NULL;
}