Skip to content
Permalink
Browse files

Add height check for Graphics.createArrayBuffer(...vertical_byte:true) (

fix #1421)
  • Loading branch information
gfwilliams committed May 18, 2018
1 parent aaaa800 commit 8a44b04b584b3d3ab1cb68fed410f7ecb165e50e
Showing with 10 additions and 2 deletions.
  1. +1 −0 ChangeLog
  2. +8 −2 libs/graphics/jswrap_graphics.c
  3. +1 −0 libs/graphics/lcd_arraybuffer.c
@@ -21,6 +21,7 @@
Make software I2C bitrate and waveform more accurate
Move default I2C bitrate to 100kbit/sec
Linux: don't create a espruino.flash file if we're not writing to flash
Add height check for Graphics.createArrayBuffer(...vertical_byte:true) (fix #1421)

1v97 : nRF52: fix NRF.on('connect',...) issue
STM32: Fix setDeviceClockCmd error for USB.setConsole()
@@ -129,8 +129,14 @@ JsVar *jswrap_graphics_createArrayBuffer(int width, int height, int bpp, JsVar *
if (jsvGetBoolAndUnLock(jsvObjectGetChild(options, "vertical_byte", 0))) {
if (gfx.data.bpp==1)
gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_VERTICAL_BYTE);
else
jsWarn("vertical_byte only works for 1bpp ArrayBuffers\n");
else {
jsExceptionHere(JSET_ERROR, "vertical_byte only works for 1bpp ArrayBuffers\n");
return 0;
}
if (gfx.data.height&7) {
jsExceptionHere(JSET_ERROR, "height must be a multiple of 8 when using vertical_byte\n");
return 0;
}
}
JsVar *colorv = jsvObjectGetChild(options, "color_order", 0);
if (colorv) {
@@ -161,6 +161,7 @@ void lcdSetPixels_ArrayBuffer_flat(JsGraphics *gfx, short x, short y, short pixe
unsigned int mask = (unsigned int)(1<<gfx->data.bpp)-1;
unsigned int existing = (unsigned int)*ptr;
unsigned int bitIdx = (gfx->data.flags & JSGRAPHICSFLAGS_ARRAYBUFFER_MSB) ? 8-(idx+gfx->data.bpp) : idx;
assert(ptr>=gfx->backendData && ptr<((char*)gfx->backendData + graphicsGetMemoryRequired(gfx)));
*ptr = (char)((existing&~(mask<<bitIdx)) | ((col&mask)<<bitIdx));
if (gfx->data.flags & JSGRAPHICSFLAGS_ARRAYBUFFER_VERTICAL_BYTE) {
ptr++;

0 comments on commit 8a44b04

Please sign in to comment.