Merge branch 'jt/commit-graph-plug-memleak'
Fix a leak noticed by fuzzer. * jt/commit-graph-plug-memleak: commit-graph: avoid memory leaks
This commit is contained in:
commit
95875e0356
@ -281,8 +281,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
|
|||||||
if (data + graph_size - chunk_lookup <
|
if (data + graph_size - chunk_lookup <
|
||||||
GRAPH_CHUNKLOOKUP_WIDTH) {
|
GRAPH_CHUNKLOOKUP_WIDTH) {
|
||||||
error(_("commit-graph chunk lookup table entry missing; file may be incomplete"));
|
error(_("commit-graph chunk lookup table entry missing; file may be incomplete"));
|
||||||
free(graph);
|
goto free_and_return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_id = get_be32(chunk_lookup + 0);
|
chunk_id = get_be32(chunk_lookup + 0);
|
||||||
@ -293,8 +292,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
|
|||||||
if (chunk_offset > graph_size - the_hash_algo->rawsz) {
|
if (chunk_offset > graph_size - the_hash_algo->rawsz) {
|
||||||
error(_("commit-graph improper chunk offset %08x%08x"), (uint32_t)(chunk_offset >> 32),
|
error(_("commit-graph improper chunk offset %08x%08x"), (uint32_t)(chunk_offset >> 32),
|
||||||
(uint32_t)chunk_offset);
|
(uint32_t)chunk_offset);
|
||||||
free(graph);
|
goto free_and_return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (chunk_id) {
|
switch (chunk_id) {
|
||||||
@ -361,8 +359,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
|
|||||||
|
|
||||||
if (chunk_repeated) {
|
if (chunk_repeated) {
|
||||||
error(_("commit-graph chunk id %08x appears multiple times"), chunk_id);
|
error(_("commit-graph chunk id %08x appears multiple times"), chunk_id);
|
||||||
free(graph);
|
goto free_and_return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_chunk_id == GRAPH_CHUNKID_OIDLOOKUP)
|
if (last_chunk_id == GRAPH_CHUNKID_OIDLOOKUP)
|
||||||
@ -381,17 +378,20 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
|
|||||||
/* We need both the bloom chunks to exist together. Else ignore the data */
|
/* We need both the bloom chunks to exist together. Else ignore the data */
|
||||||
graph->chunk_bloom_indexes = NULL;
|
graph->chunk_bloom_indexes = NULL;
|
||||||
graph->chunk_bloom_data = NULL;
|
graph->chunk_bloom_data = NULL;
|
||||||
graph->bloom_filter_settings = NULL;
|
FREE_AND_NULL(graph->bloom_filter_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashcpy(graph->oid.hash, graph->data + graph->data_len - graph->hash_len);
|
hashcpy(graph->oid.hash, graph->data + graph->data_len - graph->hash_len);
|
||||||
|
|
||||||
if (verify_commit_graph_lite(graph)) {
|
if (verify_commit_graph_lite(graph))
|
||||||
free(graph);
|
goto free_and_return;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return graph;
|
return graph;
|
||||||
|
|
||||||
|
free_and_return:
|
||||||
|
free(graph->bloom_filter_settings);
|
||||||
|
free(graph);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct commit_graph *load_commit_graph_one(const char *graph_file,
|
static struct commit_graph *load_commit_graph_one(const char *graph_file,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user