Fix filehandle leak in "git branch -D"
[gitweb.git] / builtin-write-tree.c
index 391de53972ebf77d2e08f1b405969e065bd8b371..88f34ba7d6e2426fae5169eb28b12e93e72082eb 100644 (file)
@@ -52,6 +52,8 @@ int write_tree(unsigned char *sha1, int missing_ok, const char *prefix)
        if (prefix) {
                struct cache_tree *subtree =
                        cache_tree_find(active_cache_tree, prefix);
+               if (!subtree)
+                       die("git-write-tree: prefix %s not found", prefix);
                hashcpy(sha1, subtree->sha1);
        }
        else