Commit b2df341bd0e5b6145674f4e7edb341352c3baddc

Stefan Sperling 2019-06-29T22:37:52

put error checks in right order

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/lib/repository.c b/lib/repository.c
index 3c6ad60..9211257 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -1013,12 +1013,12 @@ match_loose_object(struct got_object_id **unique_id, const char *path_objects,
 		}
 	}
 done:
+	if (dir && closedir(dir) != 0 && err == NULL)
+		err = got_error_from_errno("closedir");
 	if (err) {
 		free(*unique_id);
 		*unique_id = NULL;
 	}
-	if (dir && closedir(dir) != 0 && err == NULL)
-		err = got_error_from_errno("closedir");
 	free(path);
 	return err;
 }