Skip to content

Commit

Permalink
do not segfault if make_cache_entry failed
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Dmitry Potapov authored and Shawn O. Pearce committed Oct 6, 2008
1 parent 52e8370 commit 048f276
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -2586,6 +2586,8 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
sha1_ptr = sha1;

ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);
if (!ce)
die("make_cache_entry failed for path '%s'", name);
if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
die ("Could not add %s to temporary index", name);
}
Expand Down
2 changes: 2 additions & 0 deletions builtin-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ static int checkout_merged(int pos, struct checkout *state)
ce = make_cache_entry(create_ce_mode(active_cache[pos+1]->ce_mode),
sha1,
path, 2, 0);
if (!ce)
die("make_cache_entry failed for path '%s'", path);
status = checkout_entry(ce, state, NULL);
return status;
}
Expand Down
3 changes: 3 additions & 0 deletions builtin-reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ static void update_index_from_diff(struct diff_queue_struct *q,
struct cache_entry *ce;
ce = make_cache_entry(one->mode, one->sha1, one->path,
0, 0);
if (!ce)
die("make_cache_entry failed for path '%s'",
one->path);
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD |
ADD_CACHE_OK_TO_REPLACE);
} else
Expand Down

0 comments on commit 048f276

Please sign in to comment.