RebbleOS icon indicating copy to clipboard operation
RebbleOS copied to clipboard

Resource loader doesn't check any errors

Open ginge opened this issue 7 years ago • 0 comments

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

ginge avatar Feb 19 '18 00:02 ginge