do not segfault if make_cache_entry failed
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Dmitry Potapov committed
Oct 5, 2008 at 06:14 UTC
048f2762007d022defceb6850a44bc1bd5ccebf7
3 files changed
+7
builtin-apply.c
+2
@@ -2586,6 +2586,8 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
2586
sha1_ptr = sha1;
2587
2588
ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);
2589
+ if (!ce)
2590
+ die("make_cache_entry failed for path '%s'", name);
2591
if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
2592
die ("Could not add %s to temporary index", name);
2593
}
builtin-checkout.c
+2
@@ -206,6 +206,8 @@ static int checkout_merged(int pos, struct checkout *state)
206
ce = make_cache_entry(create_ce_mode(active_cache[pos+1]->ce_mode),
207
sha1,
208
path, 2, 0);
209
+ if (!ce)
210
+ die("make_cache_entry failed for path '%s'", path);
211
status = checkout_entry(ce, state, NULL);
212
return status;
213
}
builtin-reset.c
+3
@@ -121,6 +121,9 @@ static void update_index_from_diff(struct diff_queue_struct *q,
121
struct cache_entry *ce;
122
ce = make_cache_entry(one->mode, one->sha1, one->path,
123
0, 0);
124
+ if (!ce)
125
+ die("make_cache_entry failed for path '%s'",
126
+ one->path);
127
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD |
128
ADD_CACHE_OK_TO_REPLACE);
129
} else