]> git.sur5r.net Git - i3/i3/commitdiff
rename workspace: fix heap-use-after-free
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 8 Jan 2016 19:21:54 +0000 (20:21 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 8 Jan 2016 19:21:54 +0000 (20:21 +0100)
src/commands.c

index 03ae0ae0685ceb22f43ee977a19a6ba1627f00f1..0c6ff127df65bc0681be7866578e4114b0db7eeb 100644 (file)
@@ -2001,6 +2001,8 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
     }
 
     /* Change the name and try to parse it as a number. */
+    /* old_name might refer to workspace->name, so copy it before free()ing */
+    char *old_name_copy = sstrdup(old_name);
     FREE(workspace->name);
     workspace->name = sstrdup(new_name);
 
@@ -2041,7 +2043,8 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
     ewmh_update_desktop_viewport();
     ewmh_update_current_desktop();
 
-    startup_sequence_rename_workspace(old_name, new_name);
+    startup_sequence_rename_workspace(old_name_copy, new_name);
+    free(old_name_copy);
 }
 
 /*