RebbleOS
RebbleOS copied to clipboard
Resource loader doesn't check any errors
The resource loader currently is very optimistic. If there is an issue with a resource (say we packed the wrong image ID) and we try and load id, it can cause all kinds of crashes as we try and malloc 1GB of memory.
Add some checks to the size of loaded resources. They should be no larger that the applications current heap, and even better the free memory in the current heap (This is a little harder to implement)
Even when size sanity checks look ok, check the resource loader return values:
- When loading a PNG, check for PNG loader error codes
- When loading a font, sanity check some glyph parameter to make sure they are sane
- when loading an image and it fails, return early and safely