Code

do not segfault if make_cache_entry failed
authorDmitry Potapov <dpotapov@gmail.com>
Sun, 5 Oct 2008 02:14:40 +0000 (06:14 +0400)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 6 Oct 2008 07:49:57 +0000 (00:49 -0700)
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
builtin-apply.c
builtin-reset.c

index 70c9f93554c9bc97e5adbd924fd197973bb7d30d..2c87cf57fde83117193fad196c7f1023dcea7525 100644 (file)
@@ -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);
        }
index c24c21909194014b467c86fd3598796e7db576b3..16e6bb20f1af6a7a684a747b3c0cc26ceabe8ce7 100644 (file)
@@ -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