Commit Diff


commit - 33df9995672a4f24ded6f8cd1575637e47d27921
commit + ca6444c5b3830627626458222ef3f16852e3505f
blob - 175740d9c6f4b9443624418107f8b2314f6f44b0
blob + 17d637cabb59cb76c220d33c371c8c2a25da94cf
--- got/got.c
+++ got/got.c
@@ -7150,9 +7150,15 @@ patch_from_stdin(int *patchfd)
 	signal(SIGINT, sigint);
 	signal(SIGQUIT, sigquit);
 
-	if (err != NULL)
+	if (err == NULL && lseek(*patchfd, 0, SEEK_SET) == -1)
+		err = got_error_from_errno("lseek");
+
+	if (err != NULL) {
 		close(*patchfd);
-	return NULL;
+		*patchfd = -1;
+	}
+
+	return err;
 }
 
 static const struct got_error *