[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

@ -5,7 +5,7 @@
#include "port_management_container.h"
OpenAPI_port_management_container_t *OpenAPI_port_management_container_create(
char port_man_cont,
char *port_man_cont,
int port_num
)
{
@ -20,16 +20,22 @@ OpenAPI_port_management_container_t *OpenAPI_port_management_container_create(
void OpenAPI_port_management_container_free(OpenAPI_port_management_container_t *port_management_container)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == port_management_container) {
return;
}
OpenAPI_lnode_t *node;
if (port_management_container->port_man_cont) {
ogs_free(port_management_container->port_man_cont);
port_management_container->port_man_cont = NULL;
}
ogs_free(port_management_container);
}
cJSON *OpenAPI_port_management_container_convertToJSON(OpenAPI_port_management_container_t *port_management_container)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (port_management_container == NULL) {
ogs_error("OpenAPI_port_management_container_convertToJSON() failed [PortManagementContainer]");
@ -37,7 +43,11 @@ cJSON *OpenAPI_port_management_container_convertToJSON(OpenAPI_port_management_c
}
item = cJSON_CreateObject();
if (cJSON_AddNumberToObject(item, "portManCont", port_management_container->port_man_cont) == NULL) {
if (!port_management_container->port_man_cont) {
ogs_error("OpenAPI_port_management_container_convertToJSON() failed [port_man_cont]");
return NULL;
}
if (cJSON_AddStringToObject(item, "portManCont", port_management_container->port_man_cont) == NULL) {
ogs_error("OpenAPI_port_management_container_convertToJSON() failed [port_man_cont]");
goto end;
}
@ -54,30 +64,31 @@ end:
OpenAPI_port_management_container_t *OpenAPI_port_management_container_parseFromJSON(cJSON *port_management_containerJSON)
{
OpenAPI_port_management_container_t *port_management_container_local_var = NULL;
cJSON *port_man_cont = cJSON_GetObjectItemCaseSensitive(port_management_containerJSON, "portManCont");
OpenAPI_lnode_t *node = NULL;
cJSON *port_man_cont = NULL;
cJSON *port_num = NULL;
port_man_cont = cJSON_GetObjectItemCaseSensitive(port_management_containerJSON, "portManCont");
if (!port_man_cont) {
ogs_error("OpenAPI_port_management_container_parseFromJSON() failed [port_man_cont]");
goto end;
}
if (!cJSON_IsNumber(port_man_cont)) {
if (!cJSON_IsString(port_man_cont)) {
ogs_error("OpenAPI_port_management_container_parseFromJSON() failed [port_man_cont]");
goto end;
}
cJSON *port_num = cJSON_GetObjectItemCaseSensitive(port_management_containerJSON, "portNum");
port_num = cJSON_GetObjectItemCaseSensitive(port_management_containerJSON, "portNum");
if (!port_num) {
ogs_error("OpenAPI_port_management_container_parseFromJSON() failed [port_num]");
goto end;
}
if (!cJSON_IsNumber(port_num)) {
ogs_error("OpenAPI_port_management_container_parseFromJSON() failed [port_num]");
goto end;
}
port_management_container_local_var = OpenAPI_port_management_container_create (
port_man_cont->valueint,
ogs_strdup(port_man_cont->valuestring),
port_num->valuedouble
);