You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
local _internal_serialize = function(self, write_bytes)
for field_descriptor, field_value in message_meta._member.ListFields(self) do
field_descriptor._encoder(write_bytes, field_value)
end
end
改动:根据field的key的index排序,再进行遍历。
local _internal_serialize = function(self, write_bytes)
local field_list = {}
for k, v in pairs(self._fields) do
field_list[k.index + 1] = k
end
local n = table.maxn(field_list)
for i = 1, n do
local descriptor = field_list[i]
if descriptor then
value = self._fields[descriptor]
if _IsPresent(descriptor, value) then
descriptor._encoder(write_bytes, value)
end
end
end
end
The text was updated successfully, but these errors were encountered:
protobuf.lua中_internal_serialize函数实现,ListFields方法遍历是无序的,会导致结果不稳定,在某些情景下无法反序列化。
改动:根据field的key的index排序,再进行遍历。
The text was updated successfully, but these errors were encountered: