/src/testdir/tests/luaL_traceback_test.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include <stdint.h> |
2 | | #include <stddef.h> |
3 | | #include <string.h> |
4 | | #include <stdlib.h> |
5 | | |
6 | | #include <lua.h> |
7 | | #include <lualib.h> |
8 | | #include <lauxlib.h> |
9 | | |
10 | | |
11 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
12 | 647 | { |
13 | 647 | lua_State *L = luaL_newstate(); |
14 | 647 | if (L == NULL) |
15 | 0 | return 0; |
16 | | |
17 | 647 | char *buf = calloc(size + 1, sizeof(char)); |
18 | 647 | if (buf == NULL) |
19 | 0 | return 0; |
20 | 647 | memcpy(buf, data, size); |
21 | 647 | buf[size] = '\0'; |
22 | | |
23 | 647 | luaL_traceback(L, L, buf, 1); |
24 | | |
25 | 647 | free(buf); |
26 | 647 | lua_settop(L, 0); |
27 | 647 | lua_close(L); |
28 | | |
29 | 647 | return 0; |
30 | 647 | } |