Fix r203922 for "fortune -o": we free tpath when was_malloc is true

but don't define tpath everytime we set was_malloc to true. We end
up calling free() multiple times for the same pointer, resulting in:
<jemalloc>: jemalloc_arena.c:355: Failed assertion: ...
When we set path to offensive, we need to set tpath as well.
This commit is contained in:
Marcel Moolenaar 2013-12-07 01:35:18 +00:00
parent d4ae33f072
commit 3a3dd1fd20
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=259056

View File

@ -486,7 +486,7 @@ add_file(int percent, const char *file, const char *dir, FILEDESC **head,
if (Offend) {
if (was_malloc)
free(tpath);
path = offensive;
path = tpath = offensive;
offensive = NULL;
was_malloc = TRUE;
DPRINTF(1, (stderr, "\ttrying \"%s\"\n", path));
@ -508,7 +508,7 @@ add_file(int percent, const char *file, const char *dir, FILEDESC **head,
if (All_forts && offensive != NULL) {
if (was_malloc)
free(tpath);
path = offensive;
path = tpath = offensive;
offensive = NULL;
was_malloc = TRUE;
DPRINTF(1, (stderr, "\ttrying \"%s\"\n", path));