From a4a51eb9c7e252b79983d54de649c4e4ca9fd4b0 Mon Sep 17 00:00:00 2001 From: Dong Anyuan <donganyuan@cn.fujitsu.com> Date: Tue, 28 May 2019 20:59:50 +0900 Subject: [PATCH] Fix Coverity Scan CID 300507 (Variable lc_ue_config going out of scope leaks the storage it points to.) --- openair2/ENB_APP/flexran_agent_common.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 88db41bbe3..25fbcfc8e7 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -514,8 +514,13 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl // Fill the config for each UE for (int i = 0; i < lc_config_reply_msg->n_lc_ue_config; i++) { lc_ue_config[i] = malloc(sizeof(Protocol__FlexLcUeConfig)); - - if (!lc_ue_config[i]) goto error; + if (!lc_ue_config[i]){ + for (int j = 0; j < i; j++){ + free(lc_ue_config[j]); + } + free(lc_ue_config); + goto error; + } protocol__flex_lc_ue_config__init(lc_ue_config[i]); const int UE_id = flexran_get_mac_ue_id(mod_id, i); @@ -527,8 +532,13 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl *msg = malloc(sizeof(Protocol__FlexranMessage)); - if (*msg == NULL) + if (*msg == NULL){ + for (int k = 0; k < lc_config_reply_msg->n_lc_ue_config; k++){ + free(lc_ue_config[k]); + } + free(lc_ue_config); goto error; + } protocol__flexran_message__init(*msg); (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_LC_CONFIG_REPLY_MSG; -- GitLab