bz3_compress crash on img0.jpg file
mrfearless opened this issue · comments
Found a file that causes bz3_compress to crash. I have tried setting block size to 1MB, 65K, and the size of the file to see if that would change the result, even set the allocated memory to the bz3_bound value x2 to see if that helps also. In all cases it seems to still cause a crash.
I am attaching the img0.jpg file (stored in a zip) that is causing this issue.
Maybe its an edge case where the size of the file to be compressed is larger than the estimated bounds size for allocating memory? since its a jpeg and is compressed already. Anyhow just thought it was worth mentioning. Hopefully it can be confirmed that this file is causing a crash. Thanks in advance.
It is an edge case and weird logic in bz3_compress, which does not fudge the argument with bz3_bound to make sure that it stays in bounds:
https://github.com/kspalaiologos/bzip3/blob/master/src/libbz3.c#L807C1-L807C47
Thank you. I tested it with your fix and can confirm it is now compressing without any issues. Much appreciated, thanks again.