Skip to content

Commit

Permalink
apply: fix access to an uninitialized mode variable, found by valgrind
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Feb 4, 2009
1 parent bc39564 commit e1e4389
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e1e4389

Please sign in to comment.