aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Holler <holler@ahsoftware.de>2022-11-05 08:10:27 +0100
committerRob Landley <rob@landley.net>2022-11-05 06:57:46 -0500
commit3bc85530e160db269ec8ba5304c5d9c1899d94d7 (patch)
tree53f9d16c4d4790ee450ffbcb4ac93697f61d0542
parent0bb61e3aefc32940d8578eb174bf6e39dca17c35 (diff)
downloadtoybox-3bc85530e160db269ec8ba5304c5d9c1899d94d7.tar.gz
sh: fix bug in parameter substitution (with shortest path removal)
Avoid a core dump on the following snippet: V="a.b"; V=${V%.*}
-rw-r--r--toys/pending/sh.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 529cc5c0..298bfbc0 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -2122,7 +2122,7 @@ barf:
}
if (yy != -1) {
- if (*delete && (*delete)->arg==ifs) ifs[yy] = 0;
+ if (delete && *delete && (*delete)->arg==ifs) ifs[yy] = 0;
else push_arg(delete, ifs = xstrndup(ifs, yy));
}
}