Fixed error with the table block

Table blocks had an error where an empty table woult crash the reader
This commit is contained in:
Ryan 2017-11-12 14:05:35 -05:00
parent e3f438c4e0
commit 3facfed818
3 changed files with 19 additions and 7 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
crypto.lua

View File

@ -76,6 +76,8 @@ function bin.resolveType(tab) -- used in getblock for auto object creation. Inte
return b return b
elseif tab.Type=="sink" then elseif tab.Type=="sink" then
return bin.newSync(tab.data) return bin.newSync(tab.data)
else -- maybe a type from another library
return tab
end end
else return tab end else return tab end
end end

View File

@ -8,7 +8,9 @@ bin.registerBlock("t",function(SIZE_OR_NIL,ref)
local ind local ind
local n=0 local n=0
while true do while true do
local it,dt=ref:read(2):match("(.)(.)") local _dat=ref:read(2)
if _dat==nil then break end
local it,dt=_dat:match("(.)(.)")
n=n+2 n=n+2
if it=="N" then -- get the index stuff out of the way first if it=="N" then -- get the index stuff out of the way first
ind=ref:getBlock("n",4) ind=ref:getBlock("n",4)
@ -45,14 +47,20 @@ bin.registerBlock("t",function(SIZE_OR_NIL,ref)
local size=ref:getBlock("n",4) local size=ref:getBlock("n",4)
ref:setSeek(cur) ref:setSeek(cur)
ref:read(4) ref:read(4)
local data=bin.new(ref:read(size)) if size==7 then
local dat=data:getBlock("t") tab[ind]={}
if dat.__RECURSIVE then ref:read(7)
tab[ind]=tab n=n+11
else else
tab[ind]=dat local data=bin.new(ref:read(size))
local dat=data:getBlock("t")
if dat.__RECURSIVE then
tab[ind]=tab
else
tab[ind]=dat
end
n=n+data:getSize()+4
end end
n=n+data:getSize()+4
end end
if n==len then break end if n==len then break end
end end