diff --git a/libs/core/screen.cpp b/libs/core/screen.cpp index dff65e69..c7ab8d21 100644 --- a/libs/core/screen.cpp +++ b/libs/core/screen.cpp @@ -239,7 +239,7 @@ extern "C" void drawPanic(int code) { } bool isValidImage(Buffer buf) { - return buf->length >= 3 && buf->data[0] == 0xf0; + return buf != NULL && buf->length >= 3 && buf->data[0] == 0xf0; } /** Makes an image bound to a buffer. */ diff --git a/libs/core/screen.ts b/libs/core/screen.ts index 3f9dad5a..70ca003f 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -112,10 +112,10 @@ namespace brick { let byteWidth = (currFont.charWidth + 7) >> 3 let charSize = byteWidth * currFont.charHeight let imgBuf = output.createBuffer(2 + charSize) - let img = screen.imageOf(imgBuf) let double = (mode & Draw.Quad) ? 4 : (mode & Draw.Double) ? 2 : 1 imgBuf[0] = 0xf0 imgBuf[1] = currFont.charWidth + let img = screen.imageOf(imgBuf) while (cp < text.length) { let ch = text.charCodeAt(cp++) if (ch == 10) {