From: Michael Stapelberg Date: Fri, 8 Jan 2016 19:21:54 +0000 (+0100) Subject: rename workspace: fix heap-use-after-free X-Git-Tag: 4.12~62 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0d1aad0af427b999d7242ce41a532c9dd7ee1c69;p=i3%2Fi3 rename workspace: fix heap-use-after-free --- diff --git a/src/commands.c b/src/commands.c index 03ae0ae0..0c6ff127 100644 --- a/src/commands.c +++ b/src/commands.c @@ -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); } /*