From fc6a31fdc3a6c48633e5f3759a2357028566def1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 5 Apr 2016 15:58:25 +0200 Subject: sam: improve group handling, do not loop infinitely --- sam.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sam.c') diff --git a/sam.c b/sam.c index 5f915bc..b2b09f1 100644 --- a/sam.c +++ b/sam.c @@ -485,6 +485,8 @@ static const CommandDef *command_lookup(Vis *vis, const char *name) { } static Command *command_parse(Vis *vis, const char **s, int level, enum SamError *err) { + if (!**s) + return NULL; Command *cmd = command_new(NULL); if (!cmd) return NULL; @@ -732,7 +734,7 @@ static bool sam_execute(Vis *vis, Win *win, Command *cmd, Cursor *cur, Filerange start = text_mark_set(txt, group.start); end = text_mark_set(txt, group.end); - ret &= sam_execute(vis, win, c, cur, &group); + ret &= sam_execute(vis, win, c, NULL, &group); size_t s = text_mark_get(txt, start); /* hack to make delete work, only update if still valid */ @@ -827,7 +829,7 @@ static bool cmd_extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Cu Cursor *cursor = NULL; size_t pos = view_cursor_get(view); - if (!view_cursors_dispose(cur)) { + if (cur && !view_cursors_dispose(cur)) { cursor = view_cursors_new(view, text_size(txt)+1); view_cursors_dispose(cur); } -- cgit v1.2.3