Re: [PATCH 1/2] commit-graph, fuzz: Add fuzzer for commit-graph
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 6, 2018, 04:47 UTC
- Message-ID
- <xmqqa7lj9s8e.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <53e62baaa8769bf8e90991e32e0d123cc6629559.1544048946.git.steadmon@google.com>
Josh Steadmon <steadmon@google.com> writes:
Show 21 quoted lines
> 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; > +}