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

---
 openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c | 7 ++++++-
 1 file changed, 6 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 c15b936870..b38304742b 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
@@ -122,8 +122,13 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                         for (j = 0; j < ue_report[i]->n_rlc_report; j++) {
 
                               rlc_reports[j] = malloc(sizeof(Protocol__FlexRlcBsr));
-                              if (rlc_reports[j] == NULL)
+                              if (rlc_reports[j] == NULL){
+                                 for (k = 0; k < j; k++){
+                                   free(rlc_reports[k]);
+                                 }
+                                 free(rlc_reports);
                                  goto error;
+                              }
                               protocol__flex_rlc_bsr__init(rlc_reports[j]);
                               rlc_reports[j]->lc_id = j+1;
                               rlc_reports[j]->has_lc_id = 1;
-- 
GitLab