git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] apply: fix segfault

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 11, 2008, 22:28 UTC
Message-ID
<alpine.LSU.1.00.0802112227400.3870@racer.site>

When the patch reports a line number that is larger than the number of lines in the current version of the file, git-apply used to segfault.

This fixes it.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	This just happened to me.
 builtin-apply.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 4578542..ca7096f 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1830,7 +1830,7 @@ static int find_pos(struct image *img,
 			return try_lno;
 
 	again:
-		if (backwards_lno == 0 && forwards_lno == img->nr)
+		if (backwards_lno == 0 && forwards_lno >= img->nr)
 			break;
 
 		if (i & 1) {
-- 
1.5.4.1264.gb53928
Next: Junio C Hamano
Message 1 of 4 in “apply: fix segfault”
  1. apply: fix segfaultJohannes Schindelin, Feb 11, 2008
  2. Junio C HamanoFeb 11, 2008
  3. Junio C HamanoFeb 11, 2008
  4. Junio C HamanoFeb 11, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.