danielgtaylor / jpeg-archive

Utilities for archiving JPEGs for long term storage.
1.17k stars 121 forks source link

Fix potential cause of segfaults in smallfry #131

Open bekh6ex opened 1 year ago

bekh6ex commented 1 year ago

I occasionally run into segfaults when using jpeg-recompress -m smallfry on some images.

Explanation of the fix

This fix is required because in line 81 there is DVAL(j + 2) which is transformed into abs(old[j+2] - new[j+2]). On the last iteration in this loop j will be equal width - 2, meaning we are accessing abs(old[width] - new[width]), which in case of the last row of an image is beyond what was allocated.

bekh6ex commented 1 year ago

See libsmallfry for reference implementation