Fix a memory leak in the new directory dance in ensureDir()
This would leak the path whenever we already had the directory open. Which happens a lot. Oops.
This commit is contained in:
parent
ae2e75a129
commit
f78be76a00
|
@ -374,8 +374,6 @@ static int fsmDoMkDir(rpmPlugins plugins, int dirfd, const char *dn,
|
|||
static int ensureDir(rpmPlugins plugins, const char *p, int owned, int create,
|
||||
int quiet, int *dirfdp)
|
||||
{
|
||||
char *path = xstrdup(p);
|
||||
char *dp = path;
|
||||
char *sp = NULL, *bn;
|
||||
char *apath = NULL;
|
||||
int oflags = O_RDONLY;
|
||||
|
@ -387,6 +385,9 @@ static int ensureDir(rpmPlugins plugins, const char *p, int owned, int create,
|
|||
int dirfd = fsmOpenat(-1, "/", oflags, 1);
|
||||
int fd = dirfd; /* special case of "/" */
|
||||
|
||||
char *path = xstrdup(p);
|
||||
char *dp = path;
|
||||
|
||||
while ((bn = strtok_r(dp, "/", &sp)) != NULL) {
|
||||
fd = fsmOpenat(dirfd, bn, oflags, 1);
|
||||
/* assemble absolute path for plugins benefit, sigh */
|
||||
|
|
Loading…
Reference in New Issue