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

---
 openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
index b4a7db70e1..05de1e3721 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
@@ -409,8 +409,13 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
           for (int j = 0; j < neigh_meas->n_eutra_meas; j++ ){
 
               eutra_meas[j] = malloc(sizeof(Protocol__FlexEutraMeasurements));
-              if (eutra_meas[j] == NULL)
+              if (eutra_meas[j] == NULL) {
+                for (int k = 0 ; k < j ; k++) {
+                  free(eutra_meas[k]);
+                }
+                free(eutra_meas);
                 goto error;
+              }
 
               protocol__flex_eutra_measurements__init(eutra_meas[j]);
 
-- 
GitLab