summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-09 15:24:51 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-09 15:24:51 +0200
commitff36fbae4d4e6a18c43c0693fb16f0abfc411e32 (patch)
tree8f83ca1cfb734b640aca78347a5464cd1e904036 /utils.c
parentf51b76109f6be2bfee3e4eec61ae3f9bc3d7f8e2 (diff)
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>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/utils.c b/utils.c
index 17837377..41a04bdb 100644
--- a/utils.c
+++ b/utils.c
@@ -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;
}