Fix bad cleanup of context structure
authorDavid Goulet <david.goulet@polymtl.ca>
Sun, 17 Jul 2011 16:23:54 +0000 (12:23 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Sun, 17 Jul 2011 16:23:54 +0000 (12:23 -0400)
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
ltt-sessiond/main.c

index 75a793164d4f70843bb176ce9897522f7f811b02..73f80599c06b3491acedb298fd7e1d37d4cd569c 100644 (file)
@@ -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;
 }
 
This page took 0.036448 seconds and 4 git commands to generate.