aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-09-28 03:07:16 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-10-03 20:30:17 +0000
commit834f94a2cb9dee69031228a82196265bf541de6d (patch)
tree40e9870640d5abb28dacb68e2340f082441ebcdf
parent5c76e0aa1a32d09d1be8a9ca9461ecebd38cad87 (diff)
fix memory leak: vlr: vlr_gsupc_read_cb() must msgb_free()
Add required msgb_free() to vlr_gsupc_read_cb(). Adjust msc_vlr_tests.c gsup_rx() to *not* free the msgb again after vlr_gsupc_read_cb() did. Related: OS#2476 Change-Id: I347c53f57a7fa79921aed3f6e42599841acf27c0
-rw-r--r--src/libvlr/vlr.c1
-rw-r--r--tests/msc_vlr/msc_vlr_tests.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index 6094c9c43..adfe258db 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -804,6 +804,7 @@ int vlr_gsupc_read_cb(struct gsup_client *gsupc, struct msgb *msg)
osmo_hexdump_nospc(msgb_l2(msg), msgb_l2len(msg)));
rc = osmo_gsup_decode(msgb_l2(msg), msgb_l2len(msg), &gsup);
+ msgb_free(msg);
if (rc < 0) {
LOGP(DVLR, LOGL_ERROR,
"decoding GSUP message fails with error '%s' (%d)\n",
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index a6e0f29a0..f9dc27856 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -130,12 +130,12 @@ void gsup_rx(const char *rx_hex, const char *expect_tx_hex)
label = osmo_gsup_message_type_name(msg->l2h[0]);
fprintf(stderr, "<-- GSUP rx %s: %s\n", label,
osmo_hexdump_nospc(msgb_l2(msg), msgb_l2len(msg)));
+ /* GSUP read cb takes ownership of msgb */
rc = vlr_gsupc_read_cb(net->vlr->gsup_client, msg);
fprintf(stderr, "<-- GSUP rx %s: vlr_gsupc_read_cb() returns %d\n",
label, rc);
if (expect_tx_hex)
OSMO_ASSERT(gsup_tx_confirmed);
- talloc_free(msg);
}
bool conn_exists(struct gsm_subscriber_connection *conn)