]> git.sur5r.net Git - i3/i3/commitdiff
Fix some potential memory leaks
authorPeter Bui <pnutzh4x0r@gmail.com>
Tue, 9 Aug 2011 01:44:39 +0000 (21:44 -0400)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 9 Aug 2011 07:27:15 +0000 (09:27 +0200)
src/assignments.c
src/cfgparse.y
src/config.c
src/handlers.c
src/ipc.c

index f171dc3b2fe0cc48f51a49a6074ad9f65bb56ea3..50f4852644f3386d9b7d0269ff03fae899399447 100644 (file)
@@ -39,7 +39,9 @@ void run_assignments(i3Window *window) {
             DLOG("execute command %s\n", current->dest.command);
             char *full_command;
             asprintf(&full_command, "[id=\"%d\"] %s", window->id, current->dest.command);
-            parse_cmd(full_command);
+            char *json_result = parse_cmd(full_command);
+            FREE(full_command);
+            FREE(json_result);
         }
 
         /* Store that we ran this assignment to not execute it again */
index 59b22c6c9ef15a9188e8e9f35fb4b97ece1772e8..abbe4da0a40a90a8d0a3b856db6fe0e13a9f5a7d 100644 (file)
@@ -1101,6 +1101,7 @@ colorpixel:
         char *hex;
         if (asprintf(&hex, "#%s", $2) == -1)
             die("asprintf()");
+        free($2);
         $$ = get_colorpixel(hex);
         free(hex);
     }
index 24af35df3d1f9b8b298c7c03c34ab6b2d70fccf5..14fc6e025922c924f9c11f8f0f80493e44b1ad37 100644 (file)
@@ -193,6 +193,7 @@ static char *get_config_path(const char *override_configpath) {
     config_path = resolve_tilde("~/.i3/config");
     if (path_exists(config_path))
         return config_path;
+    free(config_path);
 
     /* 2: check for $XDG_CONFIG_HOME/i3/config */
     if ((xdg_config_home = getenv("XDG_CONFIG_HOME")) == NULL)
index 89a6bd0a1891f121472b948e8671529f7f9cadd3..b83ac83db4311dafd6e96d219d460b934ec475a8 100644 (file)
@@ -112,7 +112,8 @@ static int handle_key_press(xcb_key_press_event_t *event) {
         }
     }
 
-    parse_cmd(bind->command);
+    char *json_result = parse_cmd(bind->command);
+    free(json_result);
     return 1;
 }
 
index b2cd482c3f1ba4023a3d15d09b4db7b90540e472..d798ffa0a6bce3b5e401d28585629919a61cdb99 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -147,7 +147,8 @@ IPC_HANDLER(command) {
     char *command = scalloc(message_size + 1);
     strncpy(command, (const char*)message, message_size);
     LOG("IPC: received: *%s*\n", command);
-    const char *reply = parse_cmd((const char*)command);
+    char *reply = parse_cmd((const char*)command);
+    char *save_reply = reply;
     free(command);
 
     /* If no reply was provided, we just use the default success message */
@@ -155,6 +156,8 @@ IPC_HANDLER(command) {
         reply = "{\"success\":true}";
     ipc_send_message(fd, (const unsigned char*)reply,
                      I3_IPC_REPLY_TYPE_COMMAND, strlen(reply));
+
+    FREE(save_reply);
 }
 
 static void dump_rect(yajl_gen gen, const char *name, Rect r) {