|
| 1 | +--[[ |
| 2 | +SPDX-License-Identifier: ISC |
| 3 | +Copyright (c) 2023-2025, Sergey Bronnikov. |
| 4 | +
|
| 5 | +lua_createtable() |
| 6 | +
|
| 7 | +Creates a new empty table and pushes it onto the stack. The new |
| 8 | +table has space pre-allocated for narr array elements and nrec |
| 9 | +non-array elements. This pre-allocation is useful when you know |
| 10 | +exactly how many elements the table will have. |
| 11 | +
|
| 12 | +http://www.lua.org/manual/5.1/manual.html |
| 13 | +https://github.com/LuaJIT/LuaJIT/blob/8635cbabf3094c4d8bd00578c7d812bea87bb2d3/doc/extensions.html#L210-L216 |
| 14 | +
|
| 15 | +Bad lookup generated by lj_record_idx in GC64, |
| 16 | +https://github.com/LuaJIT/LuaJIT/issues/840 |
| 17 | +
|
| 18 | +Synopsis: table.new(narray, nhash) |
| 19 | +]] |
| 20 | + |
| 21 | +local luzer = require("luzer") |
| 22 | +local test_lib = require("lib") |
| 23 | +local MAX_INT = test_lib.MAX_INT |
| 24 | + |
| 25 | +-- PUC Rio Lua only. |
| 26 | +if test_lib.lua_version() == "LuaJIT" then |
| 27 | + print("Unsupported version.") |
| 28 | + os.exit(0) |
| 29 | +end |
| 30 | + |
| 31 | +local function TestOneInput(buf) |
| 32 | + local fdp = luzer.FuzzedDataProvider(buf) |
| 33 | + local nhash = fdp:consume_integer(0, MAX_INT) |
| 34 | + local narray = fdp:consume_integer(0, MAX_INT) |
| 35 | + table.new(narray, nhash) |
| 36 | +end |
| 37 | + |
| 38 | +local args = { |
| 39 | + artifact_prefix = "table_new_", |
| 40 | +} |
| 41 | +luzer.Fuzz(TestOneInput, nil, args) |
0 commit comments