Commit Diff


commit - 180dce26a8f1dbb0aad3e817cde76bf0e8e55517
commit + f571bb85169c90466112df17c15064e65961f877
blob - 584764a407d02c73e387e4c162da5571648b489e
blob + 5ebdc204cb0f02a844b567e7347784e9aaca74bd
--- lib/diff3.c
+++ lib/diff3.c
@@ -165,7 +165,7 @@ static const struct got_error *merge(size_t, size_t, s
 static void change(int, struct range *, int, struct diff3_state *);
 static void keep(int, struct range *, struct diff3_state *);
 static void prange(struct range *, struct diff3_state *);
-static void repos(int, struct diff3_state *);
+static const struct got_error *repos(int, struct diff3_state *);
 static void separate(const char *, struct diff3_state *);
 static const struct got_error *increase(struct diff3_state *);
 static const struct got_error *diff3_internal(char *, char *, char *,
@@ -882,6 +882,7 @@ skip(int i, int from, char *pr, struct diff3_state *d3
 static const struct got_error *
 duplicate(int *dpl, struct range *r1, struct range *r2, struct diff3_state *d3s)
 {
+	const struct got_error *err = NULL;
 	int c,d;
 	int nchar;
 	int nline;
@@ -903,24 +904,28 @@ duplicate(int *dpl, struct range *r1, struct range *r2
 			if (d == EOF)
 				return got_ferror(d3s->fp[1], GOT_ERR_EOF);
 			nchar++;
-			if (c != d) {
-				repos(nchar, d3s);
-				return NULL;
-			}
+			if (c != d)
+				return repos(nchar, d3s);
 		} while (c != '\n');
 	}
-	repos(nchar, d3s);
+	err = repos(nchar, d3s);
+	if (err)
+		return err;
 	*dpl = 1;
 	return NULL;
 }
 
-static void
+static const struct got_error *
 repos(int nchar, struct diff3_state *d3s)
 {
 	int i;
 
-	for (i = 0; i < 2; i++)
-		(void)fseek(d3s->fp[i], (long)-nchar, SEEK_CUR);
+	for (i = 0; i < 2; i++) {
+		if (fseek(d3s->fp[i], (long)-nchar, SEEK_CUR) == -1)
+			return got_ferror(d3s->fp[i], GOT_ERR_IO);
+	}
+
+	return NULL;
 }
 
 /*