]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit-graph.c
travis-ci: build with GCC 4.8 as well
[thirdparty/git.git] / commit-graph.c
index 66865acbd7489df4f85ee2454fe05a9b346e7aa7..7c5e54875fdacdf77235a077c9928f7d3bf0d001 100644 (file)
@@ -267,8 +267,10 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
                last_chunk_offset = chunk_offset;
        }
 
-       if (verify_commit_graph_lite(graph))
+       if (verify_commit_graph_lite(graph)) {
+               free(graph);
                return NULL;
+       }
 
        return graph;
 }
@@ -397,6 +399,11 @@ static void fill_commit_graph_info(struct commit *item, struct commit_graph *g,
        item->generation = get_be32(commit_data + g->hash_len + 8) >> 2;
 }
 
+static inline void set_commit_tree(struct commit *c, struct tree *t)
+{
+       c->maybe_tree = t;
+}
+
 static int fill_commit_in_graph(struct repository *r,
                                struct commit *item,
                                struct commit_graph *g, uint32_t pos)
@@ -410,7 +417,7 @@ static int fill_commit_in_graph(struct repository *r,
        item->object.parsed = 1;
        item->graph_pos = pos;
 
-       item->maybe_tree = NULL;
+       set_commit_tree(item, NULL);
 
        date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;
        date_low = get_be32(commit_data + g->hash_len + 12);
@@ -496,7 +503,7 @@ static struct tree *load_tree_for_commit(struct repository *r,
                                           GRAPH_DATA_WIDTH * (c->graph_pos);
 
        hashcpy(oid.hash, commit_data);
-       c->maybe_tree = lookup_tree(r, &oid);
+       set_commit_tree(c, lookup_tree(r, &oid));
 
        return c->maybe_tree;
 }