Commit c0a1c016337928d659e5aae2e83e7b0547ac53a6

Stefan Sperling 2019-03-15T13:11:20

move assignment closer to check in parse_ref_file()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/lib/reference.c b/lib/reference.c
index b90b966..b892f24 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -152,11 +152,12 @@ parse_ref_file(struct got_reference **ref, const char *name,
     const char *abspath)
 {
 	const struct got_error *err = NULL;
-	FILE *f = fopen(abspath, "rb");
+	FILE *f;
 	char *line;
 	size_t len;
 	const char delim[3] = {'\0', '\0', '\0'};
 
+	f = fopen(abspath, "rb");
 	if (f == NULL)
 		return NULL;