Fix a "free(): error: chunk is already free" under certain

circumstances that include circular dependencies.

PR:                     bin/91789
PR submitted by:        Frank Behrens <frank@pinky.sax.de>
Patch submitted by:     Divacky Roman <xdivac02@stud.fit.vutbr.cz>
This commit is contained in:
dougb 2006-01-17 08:01:00 +00:00
parent bc614c3af5
commit 7c81abec73

View File

@ -1,4 +1,6 @@
# if 0
/* $NetBSD: rcorder.c,v 1.7 2000/08/04 07:33:55 enami Exp $ */ /* $NetBSD: rcorder.c,v 1.7 2000/08/04 07:33:55 enami Exp $ */
#endif
/* /*
* Copyright (c) 1998, 1999 Matthew R. Green * Copyright (c) 1998, 1999 Matthew R. Green
@ -34,6 +36,8 @@
*/ */
#include <sys/types.h> #include <sys/types.h>
__FBSDID("$FreeBSD$");
#include <sys/stat.h> #include <sys/stat.h>
#include <err.h> #include <err.h>
@ -753,7 +757,8 @@ do_file(fnode)
r_tmp = r; r_tmp = r;
satisfy_req(r, fnode->filename); satisfy_req(r, fnode->filename);
r = r->next; r = r->next;
free(r_tmp); if (was_set == 0)
free(r_tmp);
} }
fnode->req_list = NULL; fnode->req_list = NULL;
@ -792,8 +797,10 @@ do_file(fnode)
} }
DPRINTF((stderr, "nuking %s\n", fnode->filename)); DPRINTF((stderr, "nuking %s\n", fnode->filename));
free(fnode->filename); if (was_set == 0) {
free(fnode); free(fnode->filename);
free(fnode);
}
} }
void void