pacman/conf.c: fix leak on error in setdefaults()
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
36fcff6e13
commit
6711d10f96
1 changed files with 14 additions and 2 deletions
|
@ -1164,12 +1164,24 @@ int setdefaults(config_t *c)
|
||||||
}
|
}
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
if(!c->dbpath) {
|
if(!c->dbpath) {
|
||||||
|
char* ppath;
|
||||||
snprintf(path, PATH_MAX, "%s/%s", rootdir, &DBPATH[1]);
|
snprintf(path, PATH_MAX, "%s/%s", rootdir, &DBPATH[1]);
|
||||||
SETDEFAULT(c->dbpath, strdup(path));
|
ppath = strdup(path);
|
||||||
|
if(ppath == NULL) {
|
||||||
|
free(rootdir);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
SETDEFAULT(c->dbpath, ppath);
|
||||||
}
|
}
|
||||||
if(!c->logfile) {
|
if(!c->logfile) {
|
||||||
|
char* ppath;
|
||||||
snprintf(path, PATH_MAX, "%s/%s", rootdir, &LOGFILE[1]);
|
snprintf(path, PATH_MAX, "%s/%s", rootdir, &LOGFILE[1]);
|
||||||
SETDEFAULT(c->logfile, strdup(path));
|
ppath = strdup(path);
|
||||||
|
if(ppath == NULL) {
|
||||||
|
free(rootdir);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
SETDEFAULT(c->logfile, ppath);
|
||||||
}
|
}
|
||||||
free(rootdir);
|
free(rootdir);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue