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

[PATCH] apply: fix access to an uninitialized mode variable, found by valgrind

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 4, 2009, 01:50 UTC
Message-ID
<alpine.DEB.1.00.0902040249030.9822@pacific.mpi-cbg.de>
In-Reply-To
<cover.1233712140u.git.johannes.schindelin@gmx.de>

When 'tpatch' was initialized successfully, st_mode was already taken from the previous diff. We should not try to override it with data from an lstat() that was never called.

This is a companion patch to 7a07841(git-apply: handle a patch that touches the same path more than once better).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin-apply.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 1e7f917..f312798 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2441,7 +2441,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 		return error("%s: %s", old_name, strerror(errno));
 	}
 
-	if (!cached)
+	if (!cached && !tpatch)
 		st_mode = ce_mode_from_stat(*ce, st->st_mode);
 
 	if (patch->is_new < 0)
-- 
1.6.1.2.582.g3fdd5
Next: Junio C Hamano
Message 1 of 5 in “apply: fix access to an uninitialized mode variable, found by valgrind”
  1. apply: fix access to an uninitialized mode variable, found by valgrindJohannes Schindelin, Feb 4, 2009
  2. Junio C HamanoFeb 4, 2009
  3. Don ZickusFeb 4, 2009
  4. Jeff KingFeb 4, 2009
  5. Johannes SchindelinFeb 4, 2009

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.