aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Matt Coffin <mcoffin13@gmail.com>2019-06-11 12:10:17 -0600
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-06-11 14:40:36 -0400
commit2b5bf78fafdf027624ca88e1f703bc9e577f4690 (patch)
treeee24a2a3740563aecfab9fdc922eafebf1527c97 /sway/tree/workspace.c
parentAdd docs for new IPC keyboard properties (diff)
downloadsway-2b5bf78fafdf027624ca88e1f703bc9e577f4690.tar.gz
sway-2b5bf78fafdf027624ca88e1f703bc9e577f4690.tar.zst
sway-2b5bf78fafdf027624ca88e1f703bc9e577f4690.zip
Fix segfaults caused by faulty command parsing
This patch fixes faulty command parsing introduced by f0f5de9a9e87ca1f0d74e7cbf82ffceba51ffbe6. When that commit allowed criteria reset on ';' delimeters in commands lists, it failed to account for its inner ','-parsing loop eating threw the entire rest of the string. This patch refactors argsep to use a list of multiple separators, and (optionally) return the separator that it matched against in this iteration via a pointer. This allows it to hint at the command parser which separator was used at the end of the last command, allowing it to trigger a potential secondary read of the criteria. Fixes #4239
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 1a1f5c49..e1ef40f4 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -212,9 +212,9 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
212 char *name = NULL; 212 char *name = NULL;
213 213
214 // workspace n 214 // workspace n
215 char *cmd = argsep(&cmdlist, " "); 215 char *cmd = argsep(&cmdlist, " ", NULL);
216 if (cmdlist) { 216 if (cmdlist) {
217 name = argsep(&cmdlist, ",;"); 217 name = argsep(&cmdlist, ",;", NULL);
218 } 218 }
219 219
220 // TODO: support "move container to workspace" bindings as well 220 // TODO: support "move container to workspace" bindings as well