pnggroup / libpng

LIBPNG: Portable Network Graphics support, official libpng repository
http://libpng.sf.net
Other
1.25k stars 611 forks source link

Skip reassignment of the initialization value #530

Open irwir opened 7 months ago

irwir commented 7 months ago

This was incorrect: Reversed condition changed to less instead of less or equal because the value still should be PNG_UINT_31_MAX. Reassignment of the same value is a common kind of copy-paste errors. Hence static analysis emits warning in this case. A better way to avoid reassignment is in the updated commit.

irwir commented 7 months ago

Thanks for reviewing. I changed the code and the description in the first message.

jbowler commented 7 months ago

libpng-ng comment: libpng(ng) shouldn't even contain this code for IDAT There is no point detecting an over-long IDAT unless it exceeds the PNG spec length (indicating a corrupted stream). IDAT buffering needs to be controlled internally to optimize the specific zlib implementation (if known) and the architecture performance; small buffers or large buffers depend on the relative speed of the zlib window copy vs the libpng row handling for large images and for small images the code can avoid the window copy entirely if enough is known about the zlib implementation.

irwir commented 7 months ago

As could be read, at least one more version of 1.6 was planned. So this code might stay for some time, while 1.7 branch did not pan out.

PS. About 5 years ago in one discussion it was suggested to rename libspng to libpng-ng. It did not happen.