|
Siteshwar Vashisht |
66f2dd |
From cc978a670597afc3251baca3a7db553f36946c22 Mon Sep 17 00:00:00 2001
|
|
Siteshwar Vashisht |
66f2dd |
From: Chet Ramey <chet.ramey@case.edu>
|
|
Siteshwar Vashisht |
66f2dd |
Date: Tue, 4 May 2021 14:29:06 -0400
|
|
Siteshwar Vashisht |
66f2dd |
Subject: [PATCH] Bash-5.1 patch 5: fix memory leaks in compound array
|
|
Siteshwar Vashisht |
66f2dd |
assignments
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
---
|
|
Siteshwar Vashisht |
66f2dd |
arrayfunc.c | 11 +++--------
|
|
Siteshwar Vashisht |
66f2dd |
patchlevel.h | 2 +-
|
|
Siteshwar Vashisht |
66f2dd |
subst.c | 2 ++
|
|
Siteshwar Vashisht |
66f2dd |
3 files changed, 6 insertions(+), 9 deletions(-)
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
diff --git a/arrayfunc.c b/arrayfunc.c
|
|
Siteshwar Vashisht |
66f2dd |
index 8231ba1e..9338dfc7 100644
|
|
Siteshwar Vashisht |
66f2dd |
--- a/arrayfunc.c
|
|
Siteshwar Vashisht |
66f2dd |
+++ b/arrayfunc.c
|
|
Siteshwar Vashisht |
66f2dd |
@@ -564,12 +564,9 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
|
|
Siteshwar Vashisht |
66f2dd |
{
|
|
Siteshwar Vashisht |
66f2dd |
WORD_LIST *list;
|
|
Siteshwar Vashisht |
66f2dd |
char *akey, *aval, *k, *v;
|
|
Siteshwar Vashisht |
66f2dd |
- int free_aval;
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
for (list = nlist; list; list = list->next)
|
|
Siteshwar Vashisht |
66f2dd |
{
|
|
Siteshwar Vashisht |
66f2dd |
- free_aval = 0;
|
|
Siteshwar Vashisht |
66f2dd |
-
|
|
Siteshwar Vashisht |
66f2dd |
k = list->word->word;
|
|
Siteshwar Vashisht |
66f2dd |
v = list->next ? list->next->word->word : 0;
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
@@ -577,24 +574,22 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
|
|
Siteshwar Vashisht |
66f2dd |
list = list->next;
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
akey = expand_assignment_string_to_string (k, 0);
|
|
Siteshwar Vashisht |
66f2dd |
- aval = expand_assignment_string_to_string (v, 0);
|
|
Siteshwar Vashisht |
66f2dd |
-
|
|
Siteshwar Vashisht |
66f2dd |
if (akey == 0 || *akey == 0)
|
|
Siteshwar Vashisht |
66f2dd |
{
|
|
Siteshwar Vashisht |
66f2dd |
err_badarraysub (k);
|
|
Siteshwar Vashisht |
66f2dd |
FREE (akey);
|
|
Siteshwar Vashisht |
66f2dd |
continue;
|
|
Siteshwar Vashisht |
66f2dd |
}
|
|
Siteshwar Vashisht |
66f2dd |
+
|
|
Siteshwar Vashisht |
66f2dd |
+ aval = expand_assignment_string_to_string (v, 0);
|
|
Siteshwar Vashisht |
66f2dd |
if (aval == 0)
|
|
Siteshwar Vashisht |
66f2dd |
{
|
|
Siteshwar Vashisht |
66f2dd |
aval = (char *)xmalloc (1);
|
|
Siteshwar Vashisht |
66f2dd |
aval[0] = '\0'; /* like do_assignment_internal */
|
|
Siteshwar Vashisht |
66f2dd |
- free_aval = 1;
|
|
Siteshwar Vashisht |
66f2dd |
}
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
bind_assoc_var_internal (var, h, akey, aval, flags);
|
|
Siteshwar Vashisht |
66f2dd |
- if (free_aval)
|
|
Siteshwar Vashisht |
66f2dd |
- free (aval);
|
|
Siteshwar Vashisht |
66f2dd |
+ free (aval);
|
|
Siteshwar Vashisht |
66f2dd |
}
|
|
Siteshwar Vashisht |
66f2dd |
}
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
diff --git a/patchlevel.h b/patchlevel.h
|
|
Siteshwar Vashisht |
66f2dd |
index e1429c24..c7f39aec 100644
|
|
Siteshwar Vashisht |
66f2dd |
--- a/patchlevel.h
|
|
Siteshwar Vashisht |
66f2dd |
+++ b/patchlevel.h
|
|
Siteshwar Vashisht |
66f2dd |
@@ -25,6 +25,6 @@
|
|
Siteshwar Vashisht |
66f2dd |
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
|
|
Siteshwar Vashisht |
66f2dd |
looks for to find the patch level (for the sccs version string). */
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
-#define PATCHLEVEL 4
|
|
Siteshwar Vashisht |
66f2dd |
+#define PATCHLEVEL 5
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
#endif /* _PATCHLEVEL_H_ */
|
|
Siteshwar Vashisht |
66f2dd |
diff --git a/subst.c b/subst.c
|
|
Siteshwar Vashisht |
66f2dd |
index 6132316a..1d24188e 100644
|
|
Siteshwar Vashisht |
66f2dd |
--- a/subst.c
|
|
Siteshwar Vashisht |
66f2dd |
+++ b/subst.c
|
|
Siteshwar Vashisht |
66f2dd |
@@ -11673,6 +11673,8 @@ expand_compound_assignment_word (tlist, flags)
|
|
Siteshwar Vashisht |
66f2dd |
free (value);
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
value = string_list (l);
|
|
Siteshwar Vashisht |
66f2dd |
+ dispose_words (l);
|
|
Siteshwar Vashisht |
66f2dd |
+
|
|
Siteshwar Vashisht |
66f2dd |
wlen = STRLEN (value);
|
|
Siteshwar Vashisht |
66f2dd |
|
|
Siteshwar Vashisht |
66f2dd |
/* Now, let's rebuild the string */
|
|
Siteshwar Vashisht |
66f2dd |
--
|
|
Siteshwar Vashisht |
66f2dd |
2.29.2
|
|
Siteshwar Vashisht |
66f2dd |
|