aboutsummaryrefslogtreecommitdiff
path: root/plugins/script
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-31 23:07:37 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-31 23:07:37 +0200
commit8ece6a4f6490c7259636b52f1ab027944f4571e0 (patch)
tree999ef1df010b698bc94fd0f1082d233ae2624817 /plugins/script
parent8fde2e72aac7a8be0de94431e1e29639929e77bf (diff)
downloadxK-8ece6a4f6490c7259636b52f1ab027944f4571e0.tar.gz
xK-8ece6a4f6490c7259636b52f1ab027944f4571e0.tar.xz
xK-8ece6a4f6490c7259636b52f1ab027944f4571e0.zip
script: fix parse_word()
With the `c > ' '` requirement we can't have an assertion for length in there.
Diffstat (limited to 'plugins/script')
-rwxr-xr-xplugins/script9
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins/script b/plugins/script
index c81aaa6..f725048 100755
--- a/plugins/script
+++ b/plugins/script
@@ -469,13 +469,16 @@ parse_word (struct tokenizer *self)
struct buffer buf = BUFFER_INITIALIZER;
char c;
- // Here we accept almost anything that doesn't break the grammar...
+ // Here we accept almost anything that doesn't break the grammar
while (!strchr (" []\"", (c = *self->cursor++)) && (unsigned char) c > ' ')
buffer_append_c (&buf, c);
self->cursor--;
- // ...so an empty word can only mean a bug within our caller.
- assert (buf.len != 0);
+ if (!buf.len)
+ {
+ self->error = "invalid input";
+ return NULL;
+ }
struct item *item = new_word (buf.s, buf.len);
free (buf.s);