diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 1fe88ecc..e68a40fb 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -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 + +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 diff --git a/arrayfunc.c b/arrayfunc.c index c2778586..95c0fef7 100644 --- a/arrayfunc.c +++ b/arrayfunc.c @@ -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] == '+') diff --git a/bashhist.c b/bashhist.c index 83119f99..3acb5724 100644 --- a/bashhist.c +++ b/bashhist.c @@ -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; diff --git a/bashline.c b/bashline.c index 8cb03259..aa9d01c2 100644 --- a/bashline.c +++ b/bashline.c @@ -3274,6 +3274,8 @@ bash_directory_expansion (dirname) free (d); *dirname = nd; } + else + free (d); } /* If necessary, rewrite directory entry */ diff --git a/builtins/trap.def b/builtins/trap.def index daeec9ea..51a92be1 100644 --- a/builtins/trap.def +++ b/builtins/trap.def @@ -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); } diff --git a/execute_cmd.c b/execute_cmd.c index 54924d3f..945e3d21 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -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 diff --git a/lib/glob/glob.c b/lib/glob/glob.c index fe6aedb1..590370c7 100644 --- a/lib/glob/glob.c +++ b/lib/glob/glob.c @@ -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); } } diff --git a/print_cmd.c b/print_cmd.c index 3c890b22..6333e70e 100644 --- a/print_cmd.c +++ b/print_cmd.c @@ -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); diff --git a/subst.c b/subst.c index 74148467..fdb79b28 100644 --- a/subst.c +++ b/subst.c @@ -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 10/2020 */ return (interactive_shell ? &expand_param_error : &expand_param_fatal); #else diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index c8bef8dd..0b063810 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -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 diff --git a/variables.c b/variables.c index d581acd8..7ede00cc 100644 --- a/variables.c +++ b/variables.c @@ -3616,6 +3616,7 @@ assign_in_env (word, flags) if (legal_identifier (name) == 0) { sh_invalidid (name); + free (name); return (0); }