Merge branch 'st/lib-gpg-kill-stray-agent'
[gitweb.git] / tree-diff.c
index 467e3817243567dadfaf853fddef8a0ef894f270..2357f72899f8f47e497ffd1bb66a0d76d7dbe012 100644 (file)
@@ -141,8 +141,7 @@ static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,
        /* if last->next is !NULL - it is a pre-allocated memory, we can reuse */
        p = last->next;
        if (p && (alloclen > (intptr_t)p->next)) {
-               free(p);
-               p = NULL;
+               FREE_AND_NULL(p);
        }
 
        if (!p) {
@@ -422,8 +421,9 @@ static struct combine_diff_path *ll_diff_tree_paths(
         *   diff_tree_oid(parent, commit) )
         */
        for (i = 0; i < nparent; ++i)
-               tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash);
-       ttree = fill_tree_descriptor(&t, oid->hash);
+               tptree[i] = fill_tree_descriptor(&tp[i],
+                               parents_oid[i] ? parents_oid[i]->hash : NULL);
+       ttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);
 
        /* Enable recursion indefinitely */
        opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);
@@ -559,8 +559,7 @@ struct combine_diff_path *diff_tree_paths(
         * (see path_appendnew() for details about why)
         */
        if (p->next) {
-               free(p->next);
-               p->next = NULL;
+               FREE_AND_NULL(p->next);
        }
 
        return p;