From 456dfeaf8e5e47b4df40815596d1225f85c03e09 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sat, 25 Sep 2021 11:22:47 +0300 Subject: [PATCH] Fix segfault on exit after opening fb2.zip (#8232) --- frontend/document/credocument.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index a13c1f796..0fdf8196b 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -71,11 +71,13 @@ local CreDocument = Document:new{ function CreDocument:zipContentExt(fname) local std_out = io.popen("unzip ".."-qql \""..fname.."\"") if std_out then + local size, ext for line in std_out:lines() do - local size, ext = string.match(line, "%s+(%d+)%s+.+%.([^.]+)") - -- return the extention - if size and ext then return string.lower(ext) end + size, ext = string.match(line, "%s+(%d+)%s+.+%.([^.]+)") + if size and ext then break end end + std_out:close() + if ext then return string.lower(ext) end end end