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.
This commit is contained in:
Tigran Aivazian
2012-09-25 17:06:49 +01:00
parent bc3c3f6a38
commit df65245e70

View File

@@ -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