Coverage Report

Created: 2025-07-11 06:33

/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
272
{
19
272
  lua_State *L = luaL_newstate();
20
272
  if (L == NULL)
21
0
    return 0;
22
23
272
  luaL_Buffer buf;
24
272
  char *s = luaL_buffinitsize(L, &buf, size);
25
272
  memcpy(s, data, size);
26
27
272
  luaL_pushresultsize(&buf, size);
28
29
272
  assert(luaL_bufflen(&buf) == size);
30
31
272
  lua_settop(L, 0);
32
272
  lua_close(L);
33
34
272
  return 0;
35
272
}