Don't free fnamebuf before we calling cfgfile_add(). This changes a

use-after-free error into a minor memory leak.

Reported by:	Coverity
CID:		1006084
This commit is contained in:
Don Lewis 2016-05-16 04:39:16 +00:00
parent b3e348206c
commit 8f2c79ef85

View File

@ -267,7 +267,8 @@ include(const char *fname, int ateof)
asprintf(&fnamebuf, "../../conf/%s", fname);
if (fnamebuf != NULL) {
fp = fopen(fnamebuf, "r");
free(fnamebuf);
if (fp == NULL)
free(fnamebuf);
}
}
if (fp == NULL) {
@ -275,10 +276,10 @@ include(const char *fname, int ateof)
asprintf(&fnamebuf, "%s/%s", ipath->path, fname);
if (fnamebuf != NULL) {
fp = fopen(fnamebuf, "r");
free(fnamebuf);
}
if (fp != NULL)
break;
free(fnamebuf);
}
}
if (fp == NULL) {