tjko / jpegoptim

jpegoptim - utility to optimize/compress JPEG files
http://www.iki.fi/tjko/projects.html
GNU General Public License v3.0
1.56k stars 116 forks source link

[Prevent NULL-ptr dereference] exit early if failed to read coefficients #120

Closed the-shank closed 1 year ago

the-shank commented 1 year ago

jpeg_read_coefficients() can return NULL under certain conditions. When this happens, the program would segfault later during the execution.

This fix checks if the return value of jpeg_read_coefficients() is NULL and exits if its NULL.

tjko commented 1 year ago

Thanks! I modified your approach slightly, so processing is not aborted, but simply skip the "broken" file, if this happens.

Does this fix the issue you noticed? 240a11526ec06f8f9e7a7dfc275bd0862f182c0d

the-shank commented 1 year ago

Yes, this would fix the issue as well. Thanks!