Skip to content

Commit

Permalink
exec: case: Free word before apply_errexit_errreturn
Browse files Browse the repository at this point in the history
Valgrind has detected a leak since the last commit. Valgrind seems to
think `word` is lost if `apply_errexit_errreturn` calls
`exit_shell_with_status` and never returns, whereas `word` would be
freed if `apply_errexit_errreturn` returned.

To suppress the false positive, this commit modifies the code so that
`word` is freed before `exit_shell_with_status` is called.
  • Loading branch information
magicant committed Oct 21, 2024
1 parent 7728c0b commit e886cf4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,9 +1423,11 @@ void exec_case(const command_T *c, bool finally_exit)
return;

fail:
free(word);
laststatus = Exit_EXPERROR;
apply_errexit_errreturn(NULL);
goto done;
if (finally_exit)
exit_shell();
}

/* Executes the function definition. */
Expand Down

0 comments on commit e886cf4

Please sign in to comment.