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
elseif tab.Type=="sink" then
return bin.newSync(tab.data)
else -- maybe a type from another library
return tab
end
else return tab end
end

View File

@ -8,7 +8,9 @@ bin.registerBlock("t",function(SIZE_OR_NIL,ref)
local ind
local n=0
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
if it=="N" then -- get the index stuff out of the way first
ind=ref:getBlock("n",4)
@ -45,14 +47,20 @@ bin.registerBlock("t",function(SIZE_OR_NIL,ref)
local size=ref:getBlock("n",4)
ref:setSeek(cur)
ref:read(4)
local data=bin.new(ref:read(size))
local dat=data:getBlock("t")
if dat.__RECURSIVE then
tab[ind]=tab
if size==7 then
tab[ind]={}
ref:read(7)
n=n+11
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
n=n+data:getSize()+4
end
if n==len then break end
end