Coverage Report

Created: 2023-09-11 06:55

/src/testdir/tests/luaL_loadbufferx_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
2.08k
{
13
2.08k
  lua_State *L = luaL_newstate();
14
2.08k
  if (L == NULL)
15
0
    return 0;
16
17
2.08k
  luaL_openlibs(L);
18
19
#ifdef LUAJIT
20
  /* See https://luajit.org/running.html. */
21
  luaL_dostring(L, "jit.opt.start('hotloop=1')");
22
  luaL_dostring(L, "jit.opt.start('hotexit=1')");
23
  luaL_dostring(L, "jit.opt.start('recunroll=1')");
24
  luaL_dostring(L, "jit.opt.start('callunroll=1')");
25
#endif /* LUAJIT */
26
27
2.08k
  const char *mode = "t";
28
2.08k
  int res = luaL_loadbufferx(L, (const char *)data, size, "fuzz", mode);
29
2.08k
  if (res == LUA_OK) {
30
1.24k
    lua_pcall(L, 0, 0, 0);
31
1.24k
  }
32
33
2.08k
  lua_settop(L, 0);
34
2.08k
  lua_close(L);
35
36
2.08k
  return 0;
37
2.08k
}