Monitor memory usage and panic on over 8MB used

This commit is contained in:
Michal Moskal
2017-12-13 15:28:52 +00:00
parent 3e2a1ec9e1
commit 67ec4accb9
3 changed files with 26 additions and 3 deletions

View File

@ -88,7 +88,7 @@ Image unpackPNG(Buffer png) {
uint32_t byteW = (hd.width + 7) >> 3;
uint32_t expSize = (byteW + 1) * hd.height;
unsigned long sz = expSize;
uint8_t *tmp = (uint8_t *)malloc(sz);
uint8_t *tmp = (uint8_t *)xmalloc(sz);
int code = uncompress(tmp, &sz, png->data + sizeof(hd), hd.lenIDAT);
if (code != 0) {
DMESG("PNG: zlib failed: %d", code);