mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-01 17:39:56 +02:00
fixes for minor memory leaks
This commit is contained in:
@@ -10734,3 +10734,46 @@ lib/readline/{complete,display,input,text,util,vi_mode}.c
|
||||
|
||||
builtins/{enable,hash,help}.def
|
||||
- enable_builtin: use sh_chkwrite after output to check for write errors
|
||||
|
||||
7/16
|
||||
----
|
||||
arrayfunc.c
|
||||
- quote_compound_array_word: free SUB and VALUE after assigning from
|
||||
sh_single_quote(). From a coverity report from
|
||||
Siteshwar Vashisht <svashisht@redhat.com>
|
||||
|
||||
bashhist.c
|
||||
- bash_remove_history_range: free DISCARD_LIST after freeing its
|
||||
elements
|
||||
|
||||
bashline.c
|
||||
- bash_directory_expansion: add code to free D as a separate branch,
|
||||
though it's never hit in practice
|
||||
|
||||
builtins/trap.def
|
||||
- showtrap: free T even if show_default == 1 if it's a non-default
|
||||
trap string
|
||||
|
||||
7/17
|
||||
----
|
||||
execute_cmd.c
|
||||
- execute_coproc: free NAME on invalid identifier error
|
||||
|
||||
lib/glob/glob.c
|
||||
- glob_vector: make sure NEXTLINK is allocated using malloc before
|
||||
passing it to free()
|
||||
- glob_filename: free RESULT before returning glob_error_return when
|
||||
there is only a filename
|
||||
|
||||
print_cmd.c
|
||||
- indirection_level_string: make sure we free PS4 after calling
|
||||
decode_prompt_string if *ps4 == 0
|
||||
|
||||
subst.c
|
||||
- parameter_brace_transform: if vtype == VT_VARIABLE, we need to free
|
||||
a non-null VAL
|
||||
|
||||
variables.c
|
||||
- assign_in_env: if NAME is not a valid shell identifier, free it
|
||||
after printing the error message and before returning. These are
|
||||
the rest of the fixes from Siteshwar Vashisht <svashisht@redhat.com>
|
||||
|
||||
@@ -906,6 +906,7 @@ quote_compound_array_word (w, type)
|
||||
nword[0] = LBRACK;
|
||||
i = STRLEN (sub);
|
||||
memcpy (nword+1, sub, i);
|
||||
free (sub);
|
||||
i++; /* accommodate the opening LBRACK */
|
||||
nword[i++] = w[ind++]; /* RBRACK */
|
||||
if (w[ind] == '+')
|
||||
|
||||
@@ -378,6 +378,7 @@ bash_delete_history_range (first, last)
|
||||
return 0;
|
||||
for (i = 0; discard_list[i]; i++)
|
||||
free_history_entry (discard_list[i]);
|
||||
free (discard_list);
|
||||
history_lines_this_session -= i;
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -3274,6 +3274,8 @@ bash_directory_expansion (dirname)
|
||||
free (d);
|
||||
*dirname = nd;
|
||||
}
|
||||
else
|
||||
free (d);
|
||||
}
|
||||
|
||||
/* If necessary, rewrite directory entry */
|
||||
|
||||
+4
-1
@@ -250,7 +250,9 @@ showtrap (i, show_default)
|
||||
int i, show_default;
|
||||
{
|
||||
char *t, *p, *sn;
|
||||
int free_t;
|
||||
|
||||
free_t = 1;
|
||||
p = trap_list[i];
|
||||
if (p == (char *)DEFAULT_SIG && signal_is_hard_ignored (i) == 0)
|
||||
{
|
||||
@@ -258,6 +260,7 @@ showtrap (i, show_default)
|
||||
t = "-";
|
||||
else
|
||||
return;
|
||||
free_t = 0;
|
||||
}
|
||||
else if (signal_is_hard_ignored (i))
|
||||
t = (char *)NULL;
|
||||
@@ -279,7 +282,7 @@ showtrap (i, show_default)
|
||||
else
|
||||
printf ("trap -- %s %s\n", t ? t : "''", sn);
|
||||
|
||||
if (show_default == 0)
|
||||
if (free_t)
|
||||
FREE (t);
|
||||
}
|
||||
|
||||
|
||||
@@ -2378,6 +2378,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close)
|
||||
if (legal_identifier (name) == 0)
|
||||
{
|
||||
internal_error (_("`%s': not a valid identifier"), name);
|
||||
free (name);
|
||||
return (invert ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
|
||||
+3
-1
@@ -936,7 +936,8 @@ glob_vector (pat, dir, flags)
|
||||
nextname = (char *) malloc (D_NAMLEN (dp) + 1);
|
||||
if (nextlink == 0 || nextname == 0)
|
||||
{
|
||||
FREE (nextlink);
|
||||
if (firstmalloc)
|
||||
FREE (nextlink);
|
||||
FREE (nextname);
|
||||
lose = 1;
|
||||
break;
|
||||
@@ -1482,6 +1483,7 @@ only_filename:
|
||||
{
|
||||
if (free_dirname)
|
||||
free (directory_name);
|
||||
free ((char *) result);
|
||||
return ((char **)&glob_error_return);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -440,7 +440,10 @@ indirection_level_string ()
|
||||
change_flag ('x', FLAG_ON);
|
||||
|
||||
if (ps4 == 0 || *ps4 == '\0')
|
||||
return (indirection_string);
|
||||
{
|
||||
FREE (ps4);
|
||||
return (indirection_string);
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
ps4_len = strnlen (ps4, MB_CUR_MAX);
|
||||
|
||||
@@ -8078,6 +8078,8 @@ parameter_brace_transform (varname, value, ind, xform, rtype, quoted, pflags, fl
|
||||
if (valid_parameter_transform (xform) == 0)
|
||||
{
|
||||
this_command_name = oname;
|
||||
if (vtype == VT_VARIABLE)
|
||||
FREE (val);
|
||||
#if 0 /* TAG: bash-5.2 Martin Schulte <gnu@schrader-schulte.de> 10/2020 */
|
||||
return (interactive_shell ? &expand_param_error : &expand_param_fatal);
|
||||
#else
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
|
||||
@@ -3616,6 +3616,7 @@ assign_in_env (word, flags)
|
||||
if (legal_identifier (name) == 0)
|
||||
{
|
||||
sh_invalidid (name);
|
||||
free (name);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user