fs-util: chase_symlinks(): prevent double free

Fixes CID #1385316.
This commit is contained in:
Yu Watanabe 2018-01-21 19:19:25 +09:00
parent 2b6d2dda6b
commit b539437a05
1 changed files with 2 additions and 2 deletions

View File

@ -834,8 +834,6 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
if (fd < 0)
return -errno;
free(done);
if (flags & CHASE_SAFE) {
if (fstat(fd, &st) < 0)
return -errno;
@ -846,6 +844,8 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
previous_stat = st;
}
free(done);
/* Note that we do not revalidate the root, we take it as is. */
if (isempty(root))
done = NULL;