Quipyowert2 / libKXL

Kacchan X Windows System Library (KXL) is a visual & sound library.
GNU General Public License v2.0
3 stars 0 forks source link

Fix infinite loop #5

Closed Quipyowert2 closed 1 year ago

Quipyowert2 commented 1 year ago

In KXL_ReadBitmapHeader(), there were a few places where execution would loop for a long time on a corrupt bitmap file, because hed->pals (the size of the hed->rgb color table) and hed->image_size were way too large, even larger than the remaining length of the file.

I've fixed the infinite loops by changing the function to bail out early if that happens. Also, I changed some exit() calls to instead simply clean up and return. Since hed->data is nulled near the beginning of ReadBitmapHeader, checking whether that's NULL is an easy way to tell if the function failed. Also, LoadBitmap can now return NULL.

TODO: