Merge branch 'jh/close-index-before-stat' into maint
[gitweb.git] / builtin / name-rev.c
index 92a5d8a5d263f78afaa2f426135998348dae53b8..e7a3fe7ee70759c34b9de12177078a55f27bfb9a 100644 (file)
@@ -28,6 +28,7 @@ static void name_rev(struct commit *commit,
        struct rev_name *name = (struct rev_name *)commit->util;
        struct commit_list *parents;
        int parent_number = 1;
+       char *to_free = NULL;
 
        parse_commit(commit);
 
@@ -35,7 +36,7 @@ static void name_rev(struct commit *commit,
                return;
 
        if (deref) {
-               tip_name = xstrfmt("%s^0", tip_name);
+               tip_name = to_free = xstrfmt("%s^0", tip_name);
 
                if (generation)
                        die("generation: %d, but deref?", generation);
@@ -53,8 +54,10 @@ static void name_rev(struct commit *commit,
                name->taggerdate = taggerdate;
                name->generation = generation;
                name->distance = distance;
-       } else
+       } else {
+               free(to_free);
                return;
+       }
 
        for (parents = commit->parents;
                        parents;