diff --git a/builtin-apply.c b/builtin-apply.c
index fc6c7083f76043168bf8024a9fa50b7f767b99bc..9641a6479a5325d5d1680d5e313a23e5d536f822 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
unsigned long backwards, forwards, try;
int backwards_lno, forwards_lno, try_lno;
- if (preimage->nr > img->nr)
- return -1;
-
/*
- * If match_begining or match_end is specified, there is no
+ * If match_beginning or match_end is specified, there is no
* point starting from a wrong line that will never match and
* wander around and wait for a match at the specified end.
*/
else if (match_end)
line = img->nr - preimage->nr;
- if (line > img->nr)
+ /*
+ * Because the comparison is unsigned, the following test
+ * will also take care of a negative line number that can
+ * result when match_end and preimage is larger than the target.
+ */
+ if ((size_t) line > img->nr)
line = img->nr;
try = 0;