/src/libpg_query/test/fuzz/fuzz_parser.c
Line | Count | Source |
1 | | #include <pg_query.h> |
2 | | |
3 | | #include <stdio.h> |
4 | | #include <stdlib.h> |
5 | | #include <string.h> |
6 | | #include <stdbool.h> |
7 | | |
8 | 167 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
9 | 167 | char *new_str = (char *)malloc(size+1); |
10 | 167 | if (new_str == NULL){ |
11 | 0 | return 0; |
12 | 0 | } |
13 | 167 | memcpy(new_str, data, size); |
14 | 167 | new_str[size] = '\0'; |
15 | | |
16 | 167 | PgQueryParseResult result = pg_query_parse(new_str); |
17 | 167 | pg_query_free_parse_result(result); |
18 | | |
19 | 167 | free(new_str); |
20 | 167 | return 0; |
21 | 167 | } |