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

---
 .../MAC/flexran_agent_mac_internal.c               | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c
index 6ce9038923..d866fe1c16 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c
@@ -303,6 +303,20 @@ Protocol__FlexUlCqiReport * copy_ul_cqi_report(Protocol__FlexUlCqiReport * origi
   return full_ul_report;
   
   error:
+    if (full_ul_report){
+      if (ul_report){
+        for (i = 0; i < full_ul_report->n_cqi_meas; i++){
+          if (ul_report[i]){
+            if ( ul_report[i]->sinr ){
+              free(ul_report[i]->sinr);
+            }
+            free(ul_report[i]);
+          }
+        }
+        free(ul_report);
+      }
+      free(full_ul_report);
+    }
     return NULL;
 }
 
-- 
GitLab