aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarehbein <arehbein@sysmocom.de>2023-02-01 23:11:03 +0100
committerarehbein <arehbein@sysmocom.de>2023-02-10 19:56:53 +0000
commit2f6e1059561109be2f5646610aa04a80be5ce0d3 (patch)
tree96bfc3d5333cda4c6f400663585d37cc6a95ff02
parentc66b812c16aaf5d79675dedb940ef3cd098441fb (diff)
common: Fix memleak in get_smscb_block()
Fix condition `block_nr == 4`, which was never reached, by effectively replacing - `4` by `msg->num_segs`, so we truly check if the current block is the last of this message - the index `block_nr` (which starts at zero) by `block_nr + 1`, so it is comparable to `msg->num_segs` Related: OS#5354 Change-Id: I3dc116d6c16c80b31712b2a969f0b2a6998b03f0
-rw-r--r--src/common/cbch.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/common/cbch.c b/src/common/cbch.c
index f65df0db..915431d8 100644
--- a/src/common/cbch.c
+++ b/src/common/cbch.c
@@ -139,12 +139,8 @@ static int get_smscb_block(struct bts_smscb_state *bts_ss, uint8_t *out, uint8_t
block_type->seq_nr = block_nr;
/* determine if this is the last block */
- if (block_nr + 1 == msg->num_segs)
- block_type->lb = 1;
- else
- block_type->lb = 0;
-
- if (block_nr == 4) {
+ block_type->lb = (block_nr + 1 == msg->num_segs);
+ if (block_type->lb) {
if (msg != bts_ss->default_msg) {
DEBUGPGT(DLSMS, g_time, "%s: deleting fully-transmitted message %p\n",
chan_name, msg);