Commit ef5e02fd4b2b09f48d9f96a78d13f6655c85ce81

Stefan Sperling 2019-08-11T18:45:18

don't clobber errno value of opendir(3); found by Hiltjo Posthuma

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/lib/fileindex.c b/lib/fileindex.c
index c4026c7..4a26baa 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -922,9 +922,10 @@ walk_dir(struct got_pathlist_entry **next, struct got_fileindex *fileindex,
 
 		subdir = opendir(subdirpath);
 		if (subdir == NULL) {
+			err = got_error_from_errno2("opendir", subdirpath);
 			free(subpath);
 			free(subdirpath);
-			return got_error_from_errno2("opendir", subdirpath);
+			return err;
 		}
 
 		err = read_dirlist(&subdirlist, subdir, subdirpath);