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
This commit is contained in:
parent
6a9679377f
commit
74478830a8
@ -560,22 +560,20 @@ rc_service_daemons_crashed(const char *service)
|
|||||||
spidfile = xmalloc(strlen(ch_root) + strlen(pidfile) + 1);
|
spidfile = xmalloc(strlen(ch_root) + strlen(pidfile) + 1);
|
||||||
strcpy(spidfile, ch_root);
|
strcpy(spidfile, ch_root);
|
||||||
strcat(spidfile, pidfile);
|
strcat(spidfile, pidfile);
|
||||||
|
free(pidfile);
|
||||||
|
pidfile = spidfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = 0;
|
pid = 0;
|
||||||
if (spidfile) {
|
if (pidfile) {
|
||||||
retval = true;
|
retval = true;
|
||||||
if ((fp = fopen(spidfile, "r"))) {
|
if ((fp = fopen(pidfile, "r"))) {
|
||||||
if (fscanf(fp, "%d", &pid) == 1)
|
if (fscanf(fp, "%d", &pid) == 1)
|
||||||
retval = false;
|
retval = false;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
free(spidfile);
|
|
||||||
spidfile = NULL;
|
|
||||||
if (ch_root) {
|
|
||||||
free(pidfile);
|
free(pidfile);
|
||||||
pidfile = NULL;
|
pidfile = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* We have the pid, so no need to match
|
/* We have the pid, so no need to match
|
||||||
on exec or name */
|
on exec or name */
|
||||||
|
Loading…
Reference in New Issue
Block a user