stb_image: fix assert failing when loading BMP
Before adoption: this commit came in with the history the project adopted, so no landing records it.
This fixes two issues with an assert failing. I tested that the first part fixes #909 and the second fixes #897. 1. Loading 16/24/32-bit BMP from memory caused an assert to fail (excluding 16-bit BMP with hsz 12). img_buffer offset was always compared with the buffer for stbi_load_from_file() but stbi_load_from_memory() uses an external buffer. Resolution: Change s->buffer_start to s->img_buffer_original. 2. Loading BMP with large header from file caused assert to fail. img_buffer points to stbi_uc buffer_start[128] but the largest BMP supported has a 138 byte header (hsz 124) causing img_buffer to wrap around to an offset of 10. The assert fails because 138 (header size) != 10 (offset in temp read buffer). Resolution: Add the previously read bytes to the offset in temp read buffer to get the absolute offset. The issues were introduced by the commit c440a53d06 ("stb_image: fix reading BMP with explicit masks").
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+7 added−3 removed
- other:+7 added−3 removed