ctrl: fix mem leak when handling GET_REPLY and SET_REPLY
In ctrl_handle_msg() (code recently propagated from handle_control_read()),
talloc_free() the parsed ctrl_cmd in all code paths. In particular, a free was
missing in case ctrl_cmd_handle() returns CTRL_CMD_HANDLED.
CTRL_CMD_HANDLED is triggered by GET_REPLY / SET_REPLY parsing, as show by
ctrl_test.c. With the memleak fixed, adjust expected test output and make a
detected mem leak abort the test immediately.
Change-Id: Id583b413f8b8bd16e5cf92a8a9e8663903646381
diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c
index 9c7316f..e25929c 100644
--- a/tests/ctrl/ctrl_test.c
+++ b/tests/ctrl/ctrl_test.c
@@ -120,9 +120,8 @@
if (talloc_total_size(ctx) != ctx_size_was) {
printf("mem leak!\n");
- // hide mem leak to be fixed in subsequent patch
- //talloc_report_full(ctx, stdout);
- //OSMO_ASSERT(false);
+ talloc_report_full(ctx, stdout);
+ OSMO_ASSERT(false);
}
printf("ok\n");