diff options
author | Calvin Lee <cyrus296@gmail.com> | 2018-01-06 19:18:06 -0700 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2018-01-06 19:20:29 -0700 |
commit | be39e84875329210beae8ceda1fb83b3bc2ffc2a (patch) | |
tree | 5701b81b0d5e8c22f89f0702271bb2b50898ba01 | |
parent | Merge pull request #1516 from AGausmann/issue-1507 (diff) | |
download | sway-be39e84875329210beae8ceda1fb83b3bc2ffc2a.tar.gz sway-be39e84875329210beae8ceda1fb83b3bc2ffc2a.tar.zst sway-be39e84875329210beae8ceda1fb83b3bc2ffc2a.zip |
Prevent invalid free of workspace name
An allocated pointer was incremented before being freed in
`sway/workspace.c` which led to an invalid free. This has been fixed by
keeping the pointer in place and moving the data instead.
Fixes #1548
-rw-r--r-- | sway/workspace.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sway/workspace.c b/sway/workspace.c index e0367190..42525f3d 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -68,8 +68,9 @@ char *workspace_next_name(const char *output_name) { | |||
68 | sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", name); | 68 | sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", name); |
69 | char *_target = strdup(name); | 69 | char *_target = strdup(name); |
70 | strip_quotes(_target); | 70 | strip_quotes(_target); |
71 | while (isspace(*_target)) | 71 | while (isspace(*_target)) { |
72 | _target++; | 72 | memmove(_target, _target+1, strlen(_target+1)); |
73 | } | ||
73 | 74 | ||
74 | // Make sure that the command references an actual workspace | 75 | // Make sure that the command references an actual workspace |
75 | // not a command about workspaces | 76 | // not a command about workspaces |