btrfs-progs: cleanup after errors in open_file_or_dir3

We should zero the dirstream in case we close it ourselves, so the
caller does not do it again. Most current callers do not do that and
exit immediatelly.

Signed-off-by: David Sterba <dsterba@suse.cz>
master
David Sterba 2015-06-09 15:24:51 +02:00
parent f51b76109f
commit ff36fbae4d
1 changed files with 3 additions and 1 deletions

View File

@ -1915,8 +1915,10 @@ int open_file_or_dir3(const char *fname, DIR **dirstream, int open_flags)
}
if (fd < 0) {
fd = -1;
if (*dirstream)
if (*dirstream) {
closedir(*dirstream);
*dirstream = NULL;
}
}
return fd;
}