From 74478830a8d035c078e986b57efd40a5c48bc896 Mon Sep 17 00:00:00 2001 From: Doug Freed Date: Mon, 12 Jan 2015 09:10:29 -0600 Subject: fix double free of pidfile This fixes a double free of the pidfile variable. For discussion of this issue, see the bug. X-Gentoo-Bug: 531600 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=531600 --- src/librc/librc-daemon.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/librc') diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index 02aff5a9..76fdd7b1 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -560,22 +560,20 @@ rc_service_daemons_crashed(const char *service) spidfile = xmalloc(strlen(ch_root) + strlen(pidfile) + 1); strcpy(spidfile, ch_root); strcat(spidfile, pidfile); + free(pidfile); + pidfile = spidfile; } pid = 0; - if (spidfile) { + if (pidfile) { retval = true; - if ((fp = fopen(spidfile, "r"))) { + if ((fp = fopen(pidfile, "r"))) { if (fscanf(fp, "%d", &pid) == 1) retval = false; fclose(fp); } - free(spidfile); - spidfile = NULL; - if (ch_root) { - free(pidfile); - pidfile = NULL; - } + free(pidfile); + pidfile = NULL; /* We have the pid, so no need to match on exec or name */ -- cgit v1.2.3