Coverage Report

Created: 2023-09-15 06:13

/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
318
{
13
318
  lua_State *L = luaL_newstate();
14
318
  if (L == NULL)
15
0
    return 0;
16
17
318
  if (size > LUAI_MAXSTACK)
18
1
    return -1;
19
20
317
  luaL_Buffer buf;
21
317
  char *s = luaL_buffinitsize(L, &buf, size);
22
317
  memcpy(s, data, size);
23
24
317
  luaL_pushresultsize(&buf, size);
25
26
317
  assert(luaL_bufflen(&buf) == size);
27
28
317
  lua_settop(L, 0);
29
317
  lua_close(L);
30
31
317
  return 0;
32
317
}