aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc/msc_a.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-12-07 18:32:35 +0300
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-12-07 18:43:00 +0300
commitc44342b88c3d768966895622d9acb3e0cc45fcf4 (patch)
tree18365d0ad016100ead8d14101bfbb02607e245aa /src/libmsc/msc_a.c
parentd405bad32db6d0af76be57d24e745ec5595bfda7 (diff)
libmsc: fix memory leak (struct msgb) in msc_i_ran_enc()
Function msc_i_ran_enc() calls msc_role_ran_encode(), but unlike the other callers of this function it does not free() the encoded message. A simple solution would be to call msgb_free(), like it's done in the other places. But a more elegant solution is to modify function msc_role_ran_encode(), so that it attaches the msgb to OTC_SELECT. This way there is no need to call msgb_free() here and there. This change fixes a memleak observed while running ttcn3-msc-test. Change-Id: I741e082badc32ba9a97c1495c894e1d22e122e3a Related: OS#5340
Diffstat (limited to 'src/libmsc/msc_a.c')
-rw-r--r--src/libmsc/msc_a.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c
index 74721d2de..c9b05728e 100644
--- a/src/libmsc/msc_a.c
+++ b/src/libmsc/msc_a.c
@@ -1659,12 +1659,9 @@ int _msc_a_msg_down(struct msc_a *msc_a, enum msc_role to_role, uint32_t to_role
.an_proto = msc_a->c.ran->an_proto,
.msg = msc_role_ran_encode(msc_a->c.fi, ran_msg),
};
- int rc;
if (!an_apdu.msg)
return -EIO;
- rc = _msub_role_dispatch(msc_a->c.msub, to_role, to_role_event, &an_apdu, file, line);
- msgb_free(an_apdu.msg);
- return rc;
+ return _msub_role_dispatch(msc_a->c.msub, to_role, to_role_event, &an_apdu, file, line);
}
int msc_a_tx_dtap_to_i(struct msc_a *msc_a, struct msgb *dtap)