mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-17 01:26:45 +00:00
[Lua] Avoid infinite loop when creating empty string (#6614)
* [Lua] Avoid infinite loop when creating empty string * [Lua] Check empty string output
This commit is contained in:
@@ -222,6 +222,18 @@ local function testCanonicalData()
|
||||
checkReadBuffer(wireData)
|
||||
end
|
||||
|
||||
local function testCreateEmptyString()
|
||||
local b = flatbuffers.Builder(0)
|
||||
local str = b:CreateString("")
|
||||
monster.Start(b)
|
||||
monster.AddName(b, str)
|
||||
b:Finish(monster.End(b))
|
||||
local s = b:Output()
|
||||
local data = flatbuffers.binaryArray.New(s)
|
||||
local mon = monster.GetRootAsMonster(data, 0)
|
||||
assert(mon:Name() == "")
|
||||
end
|
||||
|
||||
local function benchmarkMakeMonster(count, reuseBuilder)
|
||||
local fbb = reuseBuilder and flatbuffers.Builder(0)
|
||||
local length = #(generateMonster(false, fbb))
|
||||
@@ -285,6 +297,10 @@ local tests =
|
||||
f = testCanonicalData,
|
||||
d = "Tests Canonical flatbuffer file included in repo"
|
||||
},
|
||||
{
|
||||
f = testCreateEmptyString,
|
||||
d = "Avoid infinite loop when creating empty string"
|
||||
},
|
||||
{
|
||||
f = getRootAs_canAcceptString,
|
||||
d = "Tests that GetRootAs<type>() generated methods accept strings"
|
||||
|
||||
Reference in New Issue
Block a user