Coverage Report

Created: 2023-09-30 06:14

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