Skip to content

serpent.block fails with certain table keys #34

@chrisgbk

Description

@chrisgbk
local test = {
    ["a"] = true,
    ["2147483648"] = true,
    ["9223372036854775808"] = true
}
print(serpent.block(test))

The sorting function invoked by serpent.block will try to convert string keys that are also integers into integers and pass them to format.

Lua 5.2 will reject an argument to format that is larger than a 32 bit signed integer
bad argument #1 to 'format' (not a number in proper range)

Lua 5.3 will reject an argument to format that is larger than a 64 bit signed integer.
bad argument #1 to 'format' (number has no integer representation)

This causes serpent.block to crash, as it doesn't validate the number falls within the bounds of format's limits. I would expect a graceful fallback in this situation to perhaps not sorting keys that can't be represented as signed integers as integers, and sorting as strings instead.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions