Subject: | Crash with Objind 1 does not exist at index 316 at lib/PDF/API2/Basic/PDF/File.pm line 725. |
Date: | Wed, 23 Mar 2016 14:31:55 +0100 |
To: | bug-PDF-API2 [...] rt.cpan.org |
From: | Marco Pessotto <melmothx [...] gmail.com> |
See the attached patch:
diff --git a/lib/PDF/API2/Basic/PDF/File.pm b/lib/PDF/API2/Basic/PDF/File.pm
index a9bba4b..e0b6cc8 100644
--- a/lib/PDF/API2/Basic/PDF/File.pm
+++ b/lib/PDF/API2/Basic/PDF/File.pm
@@ -711,7 +711,7 @@ sub read_objnum {
my $src = $self->read_objnum($object_location->[0], 0, %opts);
die 'Cannot find the compressed object stream' unless $src;
- $src->read_stream if $src->{' nofilt'};
+ $src->read_stream(1) if $src->{' nofilt'};
my $map = substr($src->{' stream'}, 0, $src->{'First'}->val);
my $objects = substr($src->{' stream'}, $src->{'First'}->val);
From the doc, it looks like read_stream without a true argument empties
the ' stream' content in some cases, storing it on the disk. But here
the code unconditionally assumes that ' stream' is always set to a
string.
WARNING: I'm not sure the patch does the right thing, though, but
appears to work.
Attached a sample PDF which triggers the bug. I couldn't strip down the
file to have a more reasonable size, sorry.
perl -Ilib -MPDF::API2 -e 'PDF::API2->open("large-compressed.pdf");'
Objind 1 does not exist at index 316 at lib/PDF/API2/Basic/PDF/File.pm line 725.
Message body not shown because it is not plain text.
Cheers
--
Marco