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/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/5434 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 --- M src/ctrl/control_if.c M tests/ctrl/ctrl_test.c 2 files changed, 3 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/5434/1 diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index 7c1d81a..5c73b63 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -387,7 +387,6 @@ cmd->ccon = ccon; if (ctrl_cmd_handle(ctrl, cmd, ctrl->data) != CTRL_CMD_HANDLED) { ctrl_cmd_send(&ccon->write_queue, cmd); - talloc_free(cmd); } } else { cmd = talloc_zero(ccon, struct ctrl_cmd); @@ -398,9 +397,9 @@ cmd->id = "err"; cmd->reply = "Command parser error."; ctrl_cmd_send(&ccon->write_queue, cmd); - talloc_free(cmd); } + talloc_free(cmd); return 0; } diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c index 1ef5ac3..be412ea 100644 --- a/tests/ctrl/ctrl_test.c +++ b/tests/ctrl/ctrl_test.c @@ -121,9 +121,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"); -- To view, visit https://gerrit.osmocom.org/5434 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id583b413f8b8bd16e5cf92a8a9e8663903646381 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>