-
-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extract image: index out of range #804
Labels
Comments
Thanks for reporting this. PS: Always ensure you are using the latest commit. |
hhrutter
changed the title
Index out of range panic in renderIndexedRGBToPNG with certain PDFs
extract image: index out of range
Feb 25, 2024
Unfortunately I cannot share the PDF. If I come across another PDF that is not sensitive, I will update this issue. |
Understood! |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using
pdfcpu
version 0.6.0, which is the latest version as of my knowledge.OS: Ubuntu 20.04
The issue occurs with PDFs that appear to have specific characteristics in their image encoding, not tied to a specific PDF writer.
Description
I encountered a runtime panic due to an "index out of range" error in the
renderIndexedRGBToPNG
function when trying to extract images from certain PDF files usingpdfcpu
. The panic suggests an access attempt outside the bounds of an array.Steps to Reproduce
pdfcpu
to extract images from a PDF that contains indexed color space images.renderIndexedRGBToPNG
function.Expected Behavior
The function should handle the image data gracefully without causing a runtime panic, regardless of the specific content structure within the PDF.
Actual Behavior
A runtime panic occurs with the message:
panic: runtime error: index out of range [31500] with length 31500
.Proposed Solution
I've modified the
renderIndexedRGBToPNG
function to include bounds checking for both the image content array and the lookup table. This adjustment successfully resolved the panic issue in my testing. Here's the modified function:The text was updated successfully, but these errors were encountered: