From 8e599681b017b8f0fa29d6969540a8bbf2bca45f Mon Sep 17 00:00:00 2001
From: Dong Anyuan <donganyuan@cn.fujitsu.com>
Date: Thu, 20 Jun 2019 13:57:34 +0900
Subject: [PATCH] Fix Coverity Scan CID 340247 (Variable pc5s_header going out
 of scope leaks the storage it points to.)

---
 openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
index b2a7e9ddfc..dc1799ccb6 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
@@ -504,7 +504,7 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const  ctxt_pP)
   //int optval;
   int bytes_received;
   sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
-  pc5s_header_t *pc5s_header;
+  pc5s_header_t *pc5s_header = NULL;
   rb_id_t          rab_id  = 0;
   //TTN for D2D (PC5S)
   // receive a message from ProSe App
@@ -680,6 +680,10 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const  ctxt_pP)
         break;
     } /* end of switch */
   }/* end of bytes_received > 0 */
+  if (pc5s_header != NULL) {
+    free(pc5s_header);
+    pc5s_header = NULL;
+  }
 } /* pdcp_fifo_read_input_sdus_frompc5s */
 
 //-----------------------------------------------------------------------------
-- 
GitLab