Coverage Report

Created: 2023-08-27 06:20

/src/testdir/tests/luaL_bufflen_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
#include <assert.h>
6
7
#include <lua.h>
8
#include <lualib.h>
9
#include <lauxlib.h>
10
11
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
12
348
{
13
348
  lua_State *L = luaL_newstate();
14
348
  if (L == NULL)
15
0
    return 0;
16
17
348
  if (size > LUAI_MAXSTACK)
18
1
    return -1;
19
20
347
  luaL_Buffer buf;
21
347
  char *s = luaL_buffinitsize(L, &buf, size);
22
347
  memcpy(s, data, size);
23
24
347
  luaL_pushresultsize(&buf, size);
25
26
347
  assert(luaL_bufflen(&buf) == size);
27
28
347
  lua_settop(L, 0);
29
347
  lua_close(L);
30
31
347
  return 0;
32
347
}