From acc61e7c0717e4736017c1dcb0b7c3a1316918d8 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 9 Sep 2012 12:19:59 +0200 Subject: [PATCH] fix crash on documents without TOC Showing TOC on documents without one results in following error: lua config error: ./unireader.lua:1742: attempt to get length of a nil value --- unireader.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unireader.lua b/unireader.lua index b2683ecba..ae3ba9749 100644 --- a/unireader.lua +++ b/unireader.lua @@ -1738,9 +1738,11 @@ function UniReader:showToc() prev = k prev_depth = self.toc[prev].depth end -- for k,v in ipairs(self.toc) - self.toc_curidx_to_x = self.toc_children[0] - for i=1,#self.toc_children[0] do - table.insert(self.toc_cview, self.toc_xview[self.toc_children[0][i]]) + if ( self.toc_children[0] ) then + self.toc_curidx_to_x = self.toc_children[0] + for i=1,#self.toc_children[0] do + table.insert(self.toc_cview, self.toc_xview[self.toc_children[0][i]]) + end end end