Bash-5.1 patch 5: fix memory leaks in compound array assignments

This commit is contained in:
Chet Ramey
2021-05-04 14:29:06 -04:00
parent f3a35a2d60
commit cc978a6705
3 changed files with 6 additions and 9 deletions
+3 -8
View File
@@ -564,12 +564,9 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
{
WORD_LIST *list;
char *akey, *aval, *k, *v;
int free_aval;
for (list = nlist; list; list = list->next)
{
free_aval = 0;
k = list->word->word;
v = list->next ? list->next->word->word : 0;
@@ -577,24 +574,22 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
list = list->next;
akey = expand_assignment_string_to_string (k, 0);
aval = expand_assignment_string_to_string (v, 0);
if (akey == 0 || *akey == 0)
{
err_badarraysub (k);
FREE (akey);
continue;
}
aval = expand_assignment_string_to_string (v, 0);
if (aval == 0)
{
aval = (char *)xmalloc (1);
aval[0] = '\0'; /* like do_assignment_internal */
free_aval = 1;
}
bind_assoc_var_internal (var, h, akey, aval, flags);
if (free_aval)
free (aval);
free (aval);
}
}
+1 -1
View File
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 4
#define PATCHLEVEL 5
#endif /* _PATCHLEVEL_H_ */
+2
View File
@@ -11673,6 +11673,8 @@ expand_compound_assignment_word (tlist, flags)
free (value);
value = string_list (l);
dispose_words (l);
wlen = STRLEN (value);
/* Now, let's rebuild the string */