mirror of
https://github.com/gvx/bitser.git
synced 2024-11-24 06:54:20 +00:00
Close #12 (serialization bug for string "len")
Thanks to nikki93 for spotting the issue and suggesting this solution.
This commit is contained in:
parent
4f2680317c
commit
e817e4de28
@ -27,6 +27,7 @@ local buf_size = -1
|
|||||||
local buf = nil
|
local buf = nil
|
||||||
local writable_buf = nil
|
local writable_buf = nil
|
||||||
local writable_buf_size = nil
|
local writable_buf_size = nil
|
||||||
|
local SEEN_LEN = {}
|
||||||
|
|
||||||
local function Buffer_prereserve(min_size)
|
local function Buffer_prereserve(min_size)
|
||||||
if buf_size < min_size then
|
if buf_size < min_size then
|
||||||
@ -222,8 +223,8 @@ serialize_value = function(value, seen)
|
|||||||
end
|
end
|
||||||
local t = type(value)
|
local t = type(value)
|
||||||
if t ~= 'number' and t ~= 'boolean' and t ~= 'nil' then
|
if t ~= 'number' and t ~= 'boolean' and t ~= 'nil' then
|
||||||
seen[value] = seen.len
|
seen[value] = seen[SEEN_LEN]
|
||||||
seen.len = seen.len + 1
|
seen[SEEN_LEN] = seen[SEEN_LEN] + 1
|
||||||
end
|
end
|
||||||
if resource_name_registry[value] then
|
if resource_name_registry[value] then
|
||||||
local name = resource_name_registry[value]
|
local name = resource_name_registry[value]
|
||||||
@ -245,7 +246,7 @@ end
|
|||||||
|
|
||||||
local function serialize(value)
|
local function serialize(value)
|
||||||
Buffer_makeBuffer(4096)
|
Buffer_makeBuffer(4096)
|
||||||
local seen = {len = 0}
|
local seen = {[SEEN_LEN] = 0}
|
||||||
serialize_value(value, seen)
|
serialize_value(value, seen)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user