Commit 7ab0422aff525c78e854d0001ce01da9541b3cd5

Stefan Sperling 2019-03-15T12:49:08

better foarseln() error handling in open_packed_ref()

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 f548d7d..07d58e1 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -299,8 +299,12 @@ open_packed_ref(struct got_reference **ref, FILE *f, const char **subdirs,
 		abs_refname = (char *)refname;
 	do {
 		line = fparseln(f, &len, NULL, delim, 0);
-		if (line == NULL)
+		if (line == NULL) {
+			if (feof(f))
+				break;
+			err = got_ferror(f, GOT_ERR_BAD_REF_DATA);
 			break;
+		}
 		for (i = 0; i < nsubdirs; i++) {
 			if (!ref_is_absolute &&
 			    asprintf(&abs_refname, "refs/%s/%s", subdirs[i],