summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-07-24 19:49:29 +0200
committerDaniel Mack <github@zonque.org>2015-07-24 19:49:29 +0200
commitb83b298102e1abd03565052cb2bc60234e09b692 (patch)
tree84543af49bd010f6ca5ef12c4ac194cd3dfcaff5 /src/basic
parent0b071992bbdf6a2bfdbe1a064a2f8270be8779c4 (diff)
parent14e685c29d5b317b815e3e9f056648027852b07e (diff)
Merge pull request #704 from richardmaw-codethink/empty-arg-unquote
unquote_first_word: parse ` '' ` as an empty argument instead of no arg
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/util.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/basic/util.c b/src/basic/util.c
index dc20fa9baf..7896be8788 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -5729,13 +5729,19 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
case VALUE:
if (c == 0)
goto finish;
- else if (c == '\'')
+ else if (c == '\'') {
+ if (!GREEDY_REALLOC(s, allocated, sz+1))
+ return -ENOMEM;
+
state = SINGLE_QUOTE;
- else if (c == '\\')
+ } else if (c == '\\')
state = VALUE_ESCAPE;
- else if (c == '\"')
+ else if (c == '\"') {
+ if (!GREEDY_REALLOC(s, allocated, sz+1))
+ return -ENOMEM;
+
state = DOUBLE_QUOTE;
- else if (strchr(WHITESPACE, c))
+ } else if (strchr(WHITESPACE, c))
state = SPACE;
else {
if (!GREEDY_REALLOC(s, allocated, sz+2))