[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #65019] Let function segfaults when foreach return empty list
From: |
Jouke Witteveen |
Subject: |
[bug #65019] Let function segfaults when foreach return empty list |
Date: |
Tue, 12 Dec 2023 08:48:02 -0500 (EST) |
Follow-up Comment #1, bug#65019 (group make):
You are right! An even shorter way to reproduce the segfault is with
$(let a b, ,)
Having more than one variable is needed to trigger the bug. Without the
whitespace in the value list, the bug also does not trigger.
I believe the following will fix it. I hope to prepare a patch with some tests
later.
diff --git a/src/function.c b/src/function.c
index a705c8a0..4596bd90 100644
--- a/src/function.c
+++ b/src/function.c
@@ -927,7 +927,7 @@ func_let (char *o, char **argv, const char *funcname
UNUSED)
while (*vp_next != '\0')
{
p = find_next_token (&list_iterator, &len);
- if (*list_iterator != '\0')
+ if (p && *list_iterator != '\0')
{
++list_iterator;
p[len] = '\0';
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65019>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/