From 048f2762007d022defceb6850a44bc1bd5ccebf7 Mon Sep 17 00:00:00 2001 From: Dmitry Potapov Date: Sun, 5 Oct 2008 06:14:40 +0400 Subject: [PATCH] do not segfault if make_cache_entry failed Signed-off-by: Dmitry Potapov Signed-off-by: Shawn O. Pearce --- builtin-apply.c | 2 ++ builtin-checkout.c | 2 ++ builtin-reset.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/builtin-apply.c b/builtin-apply.c index e2c611bf9..342f2fe5e 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -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); } diff --git a/builtin-checkout.c b/builtin-checkout.c index b572b3bf6..3762f71aa 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -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; } diff --git a/builtin-reset.c b/builtin-reset.c index c24c21909..16e6bb20f 100644 --- a/builtin-reset.c +++ b/builtin-reset.c @@ -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 -- 2.30.2