Coverage Report

Created: 2025-10-27 06:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/testdir/tests/capi/luaL_loadbuffer_test.c
Line
Count
Source
1
/*
2
 * SPDX-License-Identifier: ISC
3
 *
4
 * Copyright 2023, Sergey Bronnikov.
5
 */
6
7
#include <stdint.h>
8
#include <stddef.h>
9
#include <string.h>
10
#include <stdlib.h>
11
12
#include "lua.h"
13
#include "lualib.h"
14
#include "lauxlib.h"
15
16
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
17
7.19k
{
18
7.19k
  lua_State *L = luaL_newstate();
19
7.19k
  if (L == NULL)
20
0
    return 0;
21
22
7.19k
  luaL_openlibs(L);
23
24
#ifdef LUAJIT
25
  /* See https://luajit.org/running.html. */
26
  luaL_dostring(L, "jit.opt.start('hotloop=1')");
27
  luaL_dostring(L, "jit.opt.start('hotexit=1')");
28
  luaL_dostring(L, "jit.opt.start('recunroll=1')");
29
  luaL_dostring(L, "jit.opt.start('callunroll=1')");
30
#endif /* LUAJIT */
31
32
7.19k
  int res = luaL_loadbuffer(L, (const char *)data, size, "fuzz");
33
7.19k
  if (res == LUA_OK) {
34
5.60k
    lua_pcall(L, 0, 0, 0);
35
5.60k
  }
36
37
7.19k
  lua_settop(L, 0);
38
7.19k
  lua_close(L);
39
40
7.19k
  return 0;
41
7.19k
}