Hopefully the final batch before 2.48-rc1
[git/gitster.git] / oss-fuzz / fuzz-parse-attr-line.c
blobe0e4bc635874a47e0ba1d04b8d92d85d42d41dc1
1 #define DISABLE_SIGN_COMPARE_WARNINGS
3 #include "git-compat-util.h"
4 #include <stddef.h>
5 #include <stdlib.h>
6 #include <stdint.h>
7 #include <string.h>
8 #include "attr.h"
10 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
12 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
14 struct match_attr *res;
15 char *buf;
17 buf = malloc(size + 1);
18 if (!buf)
19 return 0;
21 memcpy(buf, data, size);
22 buf[size] = 0;
24 res = parse_attr_line(buf, "dummy", 0, 0);
26 if (res) {
27 int j;
28 for (j = 0; j < res->num_attr; j++) {
29 const char *setto = res->state[j].setto;
30 if (ATTR_TRUE(setto) || ATTR_FALSE(setto) ||
31 ATTR_UNSET(setto))
33 else
34 free((char *)setto);
36 free(res);
38 free(buf);
40 return 0;