From 3facfed8184138660430cd6f63c80b88a80cd354 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 12 Nov 2017 14:05:35 -0500 Subject: [PATCH] Fixed error with the table block Table blocks had an error where an empty table woult crash the reader --- .gitignore | 2 ++ bin/init.lua | 2 ++ bin/support/extraBlocks.lua | 22 +++++++++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..136505d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +crypto.lua diff --git a/bin/init.lua b/bin/init.lua index 0dbc97e..77e3497 100644 --- a/bin/init.lua +++ b/bin/init.lua @@ -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 diff --git a/bin/support/extraBlocks.lua b/bin/support/extraBlocks.lua index f554cac..c204706 100644 --- a/bin/support/extraBlocks.lua +++ b/bin/support/extraBlocks.lua @@ -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