From df65245e70e6d786eb86e3bc75e8e5c4d1b5fe17 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Tue, 25 Sep 2012 17:06:49 +0100 Subject: [PATCH] Bug in CREReader:ZipContentExt(). Even after restoring to the previous version, this function had a slight bug that would cause a crash on valid .zip files (e.g. mupdf-thirdparty.zip in kindlepdfviewer make tree). The reason is because the value of s may be not nil, but the string.match() would return nil and so string.lower() would get nil as an argument and crash. So, we have to guard against this carefully. --- crereader.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crereader.lua b/crereader.lua index e780ac87c..90756ea1c 100644 --- a/crereader.lua +++ b/crereader.lua @@ -45,7 +45,14 @@ function CREReader:ZipContentExt(fname) if i > 3 then tmp:close(); break; end i = i + 1 end - return s and string.lower(string.match(s, ".+%.([^.]+)")) + if s then + local ext = string.match(s, ".+%.([^.]+)") + if ext then + ext = string.lower(ext) + return ext + end + end + return nil end -- open a CREngine supported file and its settings store