Skip to content

Commit e1e4389

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc39564 commit e1e4389

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin-apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
24452445
return error("%s: %s", old_name, strerror(errno));
24462446
}
24472447

2448-
if (!cached)
2448+
if (!cached && !tpatch)
24492449
st_mode = ce_mode_from_stat(*ce, st->st_mode);
24502450

24512451
if (patch->is_new < 0)

0 commit comments

Comments
 (0)