From ba81c62eb7efd1ba9819ed3e07d5e5c86fd1d9c7 Mon Sep 17 00:00:00 2001
From: Dong Anyuan <donganyuan@cn.fujitsu.com>
Date: Tue, 28 May 2019 21:14:05 +0900
Subject: [PATCH] Fix Coverity Scan CID 300496 (Variable header going out of
 scope leaks the storage it points to.)

---
 openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
index a5742a5d43..257cd444e2 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
@@ -1075,6 +1075,7 @@ int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMess
   Protocol__FlexDlMacConfig *dl_mac_config_msg;
   dl_mac_config_msg = malloc(sizeof(Protocol__FlexDlMacConfig));
   if (dl_mac_config_msg == NULL) {
+    free(header);
     goto error;
   }
   protocol__flex_dl_mac_config__init(dl_mac_config_msg);
@@ -1084,8 +1085,10 @@ int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMess
   dl_mac_config_msg->sfn_sf = flexran_get_sfn_sf(mod_id);
 
   *msg = malloc(sizeof(Protocol__FlexranMessage));
-  if(*msg == NULL)
+  if(*msg == NULL) {
+    free(header);
     goto error;
+  }
   protocol__flexran_message__init(*msg);
   (*msg)->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_DL_MAC_CONFIG_MSG;
   (*msg)->msg_dir =  PROTOCOL__FLEXRAN_DIRECTION__INITIATING_MESSAGE;
-- 
2.26.2