From a2fb29a51133de95720cc389121f403c21b25b8f Mon Sep 17 00:00:00 2001 From: David Goulet Date: Sun, 17 Jul 2011 12:23:54 -0400 Subject: [PATCH] Fix bad cleanup of context structure Signed-off-by: David Goulet --- ltt-sessiond/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 75a793164..73f80599c 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -226,18 +226,18 @@ static int send_unix_sock(int sock, void *buf, size_t len) * * Free memory of a command context structure. */ -static void clean_command_ctx(struct command_ctx *cmd_ctx) +static void clean_command_ctx(struct command_ctx **cmd_ctx) { - DBG("Clean command context structure %p", cmd_ctx); - if (cmd_ctx) { - if (cmd_ctx->llm) { - free(cmd_ctx->llm); + DBG("Clean command context structure"); + if (*cmd_ctx) { + if ((*cmd_ctx)->llm) { + free((*cmd_ctx)->llm); } - if (cmd_ctx->lsm) { - free(cmd_ctx->lsm); + if ((*cmd_ctx)->lsm) { + free((*cmd_ctx)->lsm); } - free(cmd_ctx); - cmd_ctx = NULL; + free(*cmd_ctx); + *cmd_ctx = NULL; } } @@ -2081,7 +2081,7 @@ static void *thread_manage_clients(void *data) /* TODO: Inform client somehow of the fatal error. At this point, * ret < 0 means that a malloc failed (ENOMEM). */ /* Error detected but still accept command */ - clean_command_ctx(cmd_ctx); + clean_command_ctx(&cmd_ctx); continue; } @@ -2092,7 +2092,7 @@ static void *thread_manage_clients(void *data) ERR("Failed to send data back to client"); } - clean_command_ctx(cmd_ctx); + clean_command_ctx(&cmd_ctx); /* End of transmission */ close(sock); @@ -2109,7 +2109,7 @@ error: unlink(client_unix_sock_path); - clean_command_ctx(cmd_ctx); + clean_command_ctx(&cmd_ctx); return NULL; } -- 2.34.1