Skip to content

Commit

Permalink
[Minor] Fix one corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Sep 28, 2023
1 parent 2a04d19 commit f9962fb
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lualib/lua_content/pdf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -428,18 +428,23 @@ local function maybe_extract_object_stream(obj, pdf, task)
if dict.Length and type(obj.stream) == 'table' then
local len = math.min(obj.stream.len,
tonumber(maybe_dereference_object(dict.Length, pdf, task)) or 0)
local real_stream = obj.stream.data:span(1, len)
if len > 0 then
local real_stream = obj.stream.data:span(1, len)

local uncompressed, filter_err = maybe_apply_filter(dict, real_stream, pdf, task)
local uncompressed, filter_err = maybe_apply_filter(dict, real_stream, pdf, task)

if uncompressed then
obj.uncompressed = uncompressed
lua_util.debugm(N, task, 'extracted object %s:%s: (%s -> %s)',
obj.major, obj.minor, len, uncompressed:len())
return obj.uncompressed
if uncompressed then
obj.uncompressed = uncompressed
lua_util.debugm(N, task, 'extracted object %s:%s: (%s -> %s)',
obj.major, obj.minor, len, uncompressed:len())
return obj.uncompressed
else
lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s; filter = %s: %s',
obj.major, obj.minor, len, dict.Filter, filter_err)
end
else
lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s; filter = %s: %s',
obj.major, obj.minor, len, dict.Filter, filter_err)
lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s',
obj.major, obj.minor, len)
end
end
end
Expand Down

0 comments on commit f9962fb

Please sign in to comment.