Coverage Report

Created: 2025-08-29 06:37

/src/testdir/tests/capi/luaL_bufflen_test.c
Line
Count
Source (jump to first uncovered line)
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
#include <assert.h>
12
13
#include "lua.h"
14
#include "lualib.h"
15
#include "lauxlib.h"
16
17
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
18
232
{
19
232
  lua_State *L = luaL_newstate();
20
232
  if (L == NULL)
21
0
    return 0;
22
23
232
  luaL_Buffer buf;
24
232
  char *s = luaL_buffinitsize(L, &buf, size);
25
232
  memcpy(s, data, size);
26
27
232
  luaL_pushresultsize(&buf, size);
28
29
232
  assert(luaL_bufflen(&buf) == size);
30
31
232
  lua_settop(L, 0);
32
232
  lua_close(L);
33
34
232
  return 0;
35
232
}