@matheusbsbs / matheus-bagliano / commits / d09e2cd551
Fork 0

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 d09e2cd5516473753cb067e723293fab180e0b1b
2 files changed +5
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-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