lvandeve / lodepng

PNG encoder and decoder in C and C++.
zlib License
2.06k stars 421 forks source link

Loading large images #70

Closed Derpalus closed 6 years ago

Derpalus commented 6 years ago

I was trying to open a 38364 x 18372 pixel RGBA 8 bit png and got the 92 error. I tracked it to this line: if(numpixels > 268435455) CERROR_RETURN(state->error, 92). For testing purposes I removed it and tried to open the file again, and as far as I can tell it opened perferctly fine in my 64 bit application.

What I wonder is if this is something left from 32 bit limitations or if this is still relevant and I'm playing with fire? From cursory examination it seems that all important variables are size_t which are large enough on 64 bit compilations.

lvandeve commented 6 years ago

It's a protection against possible buffer overflows and undefined behavior, but you're right that it should be possible if you have 64-bit values. Allowing it if sizeof(size_t) >= 8 might be sufficient, but I'd need to look slightly better that no edge cases are missed. I'll look into it. Thanks for reporting this

lvandeve commented 6 years ago

This should have fixed it: https://github.com/lvandeve/lodepng/commit/9426bf43031a3b0c37bc0c19b97448f316f5cf7e

Does it work for you?

Thanks!

lvandeve commented 6 years ago

Feel free to reopen if not :)

lukeeey commented 5 years ago

You cant reopen issues closed by the repo owner

lvandeve commented 5 years ago

Oh, in that case please reply if it doesn't work. Thanks!