[PATCH] openbsc[master]: tests/bsc & bsc-nat: fix mem leaks of talloc ctx

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Sat Feb 4 03:52:15 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1752

to look at the new patch set (#2).

tests/bsc & bsc-nat: fix mem leaks of talloc ctx

When using talloc with a NULL context an anonymous ctx will be created,
but never freed.

Found by ASAN.

Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615
---
M openbsc/tests/bsc-nat/bsc_nat_test.c
M openbsc/tests/bsc/bsc_test.c
2 files changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/52/1752/2

diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 2914a01..32a0432 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -1551,7 +1551,8 @@
 
 int main(int argc, char **argv)
 {
-	msgb_talloc_ctx_init(NULL, 0);
+	void *tctx = talloc_named_const(NULL, 0, "bsc_nat_test");
+	msgb_talloc_ctx_init(tctx, 0);
 	sccp_set_log_area(DSCCP);
 	osmo_init_logging(&log_info);
 
@@ -1572,7 +1573,7 @@
 	test_mgcp_allocations();
 	test_barr_list_parsing();
 	test_nat_extract_lac();
-
+	talloc_free(tctx);
 	printf("Testing execution completed.\n");
 	return 0;
 }
diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c
index 7174828..6850b31 100644
--- a/openbsc/tests/bsc/bsc_test.c
+++ b/openbsc/tests/bsc/bsc_test.c
@@ -199,11 +199,12 @@
 
 int main(int argc, char **argv)
 {
-	msgb_talloc_ctx_init(NULL, 0);
+	void *tctx = talloc_named_const(NULL, 0, "bsc_test");
+	msgb_talloc_ctx_init(tctx, 0);
 	osmo_init_logging(&log_info);
 
 	test_scan();
-
+	talloc_free(tctx);
 	printf("Testing execution completed.\n");
 	return 0;
 }

-- 
To view, visit https://gerrit.osmocom.org/1752
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list