summaryrefslogtreecommitdiff
path: root/builtin-apply.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2009-02-04 01:50:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-02-04 06:04:31 (GMT)
commite1e4389832f32bb6ce029d6a6b110aa9ec768ea8 (patch)
treecb35c5a36915c4f2a93d26d9e4768fa3dc7e530b /builtin-apply.c
parentbc395643b606ffe7a5c01e2772ae0644c840f368 (diff)
downloadgit-e1e4389832f32bb6ce029d6a6b110aa9ec768ea8.zip
git-e1e4389832f32bb6ce029d6a6b110aa9ec768ea8.tar.gz
git-e1e4389832f32bb6ce029d6a6b110aa9ec768ea8.tar.bz2
apply: fix access to an uninitialized mode variable, found by valgrind
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-apply.c')
-rw-r--r--builtin-apply.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin-apply.c b/builtin-apply.c
index 50b623e..7a1ff04 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2445,7 +2445,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)