From ff53cde795f160e0ee86ad17f09750c2ee2085f1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Jul 2014 13:51:06 +0000 Subject: [PATCH] lib: Fix a valgrind error See the comment inside Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher --- source3/lib/background.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source3/lib/background.c b/source3/lib/background.c index a9fd04f6a4a..869f2ef4750 100644 --- a/source3/lib/background.c +++ b/source3/lib/background.c @@ -181,7 +181,18 @@ static void background_job_waited(struct tevent_req *subreq) if (written == -1) { _exit(1); } - TALLOC_FREE(state->msg); + + /* + * No TALLOC_FREE here, messaging_parent_dgm_cleanup_init for + * example calls background_job_send with "messaging_context" + * as talloc parent. Thus "state" will be freed with the + * following talloc_free will have removed "state" when it + * returns. TALLOC_FREE will then write a NULL into free'ed + * memory. talloc_free() is required although we immediately + * exit, the messaging_context's destructor will want to clean + * up. + */ + talloc_free(state->msg); _exit(0); } -- 2.11.4.GIT