rename workspace: fix heap-use-after-free

This commit is contained in:
Michael Stapelberg 2016-01-08 20:21:54 +01:00
parent 55bc2ae6a9
commit 0d1aad0af4
1 changed files with 4 additions and 1 deletions

View 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);
}
/*