From 0e6b0f3e7a1427c3b81be7220cb7dd0331fc7caf Mon Sep 17 00:00:00 2001
From: Bartosz Podrygajlo <bartosz.podrygajlo@openairinterface.org>
Date: Wed, 26 Jun 2024 17:17:01 +0200
Subject: [PATCH] Fix memory leak in rlc_test_5 and rlc_test_6

---
 openair2/LAYER2/nr_rlc/nr_rlc_entity.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c
index 0e07e14fc98..a4207716f55 100644
--- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c
+++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c
@@ -110,11 +110,8 @@ nr_rlc_entity_t *new_nr_rlc_entity_am(
   ret->max_retx_threshold = max_retx_threshold;
   ret->sn_field_length    = sn_field_length;
 
-  if (!(sn_field_length == 12 || sn_field_length == 18)) {
-    LOG_E(RLC, "%s:%d:%s: wrong SN field_lenght (%d), must be 12 or 18\n",
-          __FILE__, __LINE__, __FUNCTION__, sn_field_length);
-    exit(1);
-  }
+  AssertFatal(sn_field_length == 12 || sn_field_length == 18, "Wrong SN field_length (%d), must be 12 or 18\n", sn_field_length);
+
   ret->sn_modulus = 1 << ret->sn_field_length;
   ret->window_size = ret->sn_modulus / 2;
 
@@ -172,11 +169,8 @@ nr_rlc_entity_t *new_nr_rlc_entity_um(
   ret->t_reassembly    = t_reassembly;
   ret->sn_field_length = sn_field_length;
 
-  if (!(sn_field_length == 6 || sn_field_length == 12)) {
-    LOG_E(RLC, "%s:%d:%s: wrong SN field_lenght (%d), must be 6 or 12\n",
-          __FILE__, __LINE__, __FUNCTION__, sn_field_length);
-    exit(1);
-  }
+  AssertFatal(sn_field_length == 6 || sn_field_length == 12, "Wrong SN field_length (%d), must be 6 or 12\n", sn_field_length);
+
   ret->sn_modulus = 1 << ret->sn_field_length;
   ret->window_size = ret->sn_modulus / 2;
 
-- 
GitLab