From: Junio C Hamano Date: Thu, 06 Dec 2018 04:47:13 GMT Subject: Re: [PATCH 1/2] commit-graph, fuzz: Add fuzzer for commit-graph Message-ID: In-Reply-To: <53e62baaa8769bf8e90991e32e0d123cc6629559.1544048946.git.steadmon@google.com> Josh Steadmon writes: > diff --git a/fuzz-commit-graph.c b/fuzz-commit-graph.c > new file mode 100644 > index 0000000000..420851d0d2 > --- /dev/null > +++ b/fuzz-commit-graph.c > @@ -0,0 +1,18 @@ > +#include "object-store.h" > +#include "commit-graph.h" > + > +struct commit_graph *parse_commit_graph(void *graph_map, int fd, > + size_t graph_size); > + > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); > + > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) > +{ > + struct commit_graph *g; > + > + g = parse_commit_graph((void *) data, -1, size); > + if (g) > + free(g); As it is perfectly OK to free(NULL), please lose "if (g)" and a level of indentation; otherwise, "make coccicheck" would complain. Thanks. > + return 0; > +}