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>
Johannes Schindelin committed
Feb 4, 2009 at 02:50 UTC
e1e4389832f32bb6ce029d6a6b110aa9ec768ea8
1 file changed
+1
-1
builtin-apply.c
+1
-1
@@ -2445,7 +2445,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
2445
return error("%s: %s", old_name, strerror(errno));
2446
}
2447
2448
- if (!cached)
2448
+ if (!cached && !tpatch)
2449
st_mode = ce_mode_from_stat(*ce, st->st_mode);
2450
2451
if (patch->is_new < 0)