commit-graph: fix memory leak
authorJosh Steadmon <steadmon@google.com>
Mon, 6 May 2019 21:36:58 +0000 (14:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 May 2019 04:49:28 +0000 (13:49 +0900)
Free the commit graph when verify_commit_graph_lite() reports an error.
Credit to OSS-Fuzz for finding this leak.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c
index 66865acbd7489df4f85ee2454fe05a9b346e7aa7..4bce70d35c9baaa5504c7a15d8208d7ffc185df8 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;
 }