|
| 1 | +--[[ |
| 2 | +SPDX-License-Identifier: ISC |
| 3 | +Copyright (c) 2023-2025, Sergey Bronnikov. |
| 4 | +
|
| 5 | +Bad lookup generated by lj_record_idx in GC64, |
| 6 | +https://github.com/LuaJIT/LuaJIT/issues/840 |
| 7 | +
|
| 8 | +Synopsis: |
| 9 | + LuaJIT: table.new(narray, nhash) |
| 10 | + PUC Rio Lua: table.create(narray, nhash) |
| 11 | +]] |
| 12 | + |
| 13 | +local luzer = require("luzer") |
| 14 | +local test_lib = require("lib") |
| 15 | + |
| 16 | +local table_create |
| 17 | +if test_lib.lua_version() == "LuaJIT" then |
| 18 | + table_create = require("table.new") |
| 19 | +elseif test_lib.lua_current_version_lt_than(5, 5) then |
| 20 | + -- New function 'table.create()' in PUC Rio Lua, |
| 21 | + -- https://github.com/lua/lua/commit/3e9dbe143d3338f5f13a5e421ea593adff482da0 |
| 22 | + table_create = table.create |
| 23 | +else |
| 24 | + print("Unsupported version.") |
| 25 | + os.exit(0) |
| 26 | +end |
| 27 | + |
| 28 | +local function TestOneInput(buf) |
| 29 | + local fdp = luzer.FuzzedDataProvider(buf) |
| 30 | + -- Beware, huge number triggers OOM or table overflow. |
| 31 | + local MAX_N = 1000 |
| 32 | + local narray = fdp:consume_integer(0, MAX_N) |
| 33 | + local nhash = fdp:consume_integer(0, MAX_N) |
| 34 | + local _ = table_create(narray, nhash) -- luacheck: no unused |
| 35 | +end |
| 36 | + |
| 37 | +local args = { |
| 38 | + artifact_prefix = "table_create_", |
| 39 | +} |
| 40 | +luzer.Fuzz(TestOneInput, nil, args) |
0 commit comments