From 3bc85530e160db269ec8ba5304c5d9c1899d94d7 Mon Sep 17 00:00:00 2001 From: Alexander Holler Date: Sat, 5 Nov 2022 08:10:27 +0100 Subject: [PATCH] sh: fix bug in parameter substitution (with shortest path removal) Avoid a core dump on the following snippet: V="a.b"; V=${V%.*} --- toys/pending/sh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)); } } -- 2.39.2