@@ -281,8 +281,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
281
281
if (data + graph_size - chunk_lookup <
282
282
GRAPH_CHUNKLOOKUP_WIDTH ) {
283
283
error (_ ("commit-graph chunk lookup table entry missing; file may be incomplete" ));
284
- free (graph );
285
- return NULL ;
284
+ goto free_and_return ;
286
285
}
287
286
288
287
chunk_id = get_be32 (chunk_lookup + 0 );
@@ -293,8 +292,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
293
292
if (chunk_offset > graph_size - the_hash_algo -> rawsz ) {
294
293
error (_ ("commit-graph improper chunk offset %08x%08x" ), (uint32_t )(chunk_offset >> 32 ),
295
294
(uint32_t )chunk_offset );
296
- free (graph );
297
- return NULL ;
295
+ goto free_and_return ;
298
296
}
299
297
300
298
switch (chunk_id ) {
@@ -361,8 +359,7 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
361
359
362
360
if (chunk_repeated ) {
363
361
error (_ ("commit-graph chunk id %08x appears multiple times" ), chunk_id );
364
- free (graph );
365
- return NULL ;
362
+ goto free_and_return ;
366
363
}
367
364
368
365
if (last_chunk_id == GRAPH_CHUNKID_OIDLOOKUP )
@@ -381,17 +378,20 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size)
381
378
/* We need both the bloom chunks to exist together. Else ignore the data */
382
379
graph -> chunk_bloom_indexes = NULL ;
383
380
graph -> chunk_bloom_data = NULL ;
384
- graph -> bloom_filter_settings = NULL ;
381
+ FREE_AND_NULL ( graph -> bloom_filter_settings ) ;
385
382
}
386
383
387
384
hashcpy (graph -> oid .hash , graph -> data + graph -> data_len - graph -> hash_len );
388
385
389
- if (verify_commit_graph_lite (graph )) {
390
- free (graph );
391
- return NULL ;
392
- }
386
+ if (verify_commit_graph_lite (graph ))
387
+ goto free_and_return ;
393
388
394
389
return graph ;
390
+
391
+ free_and_return :
392
+ free (graph -> bloom_filter_settings );
393
+ free (graph );
394
+ return NULL ;
395
395
}
396
396
397
397
static struct commit_graph * load_commit_graph_one (const char * graph_file ,
0 commit comments