Fix potential out of bounds Graphics.scroll

This commit is contained in:
Gordon Williams 2018-10-22 10:48:58 +01:00
parent 4fbd56e487
commit 3d63b355ea
3 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,7 @@
Fix issues with Class Extends
Improve Tab Completions for extended classes
Fix Storage.readJSON/readArrayBuffer memory leak (fix #1532)
Fix potential out of bounds Graphics.scroll
2v00 : Allow changeInterval with large (>32 bit) intervals (fix #1438)
changeInterval now changes the interval immediately when it's called inside the interval it is changing (fix #1440)

View File

@ -73,7 +73,7 @@ void graphicsFallbackScroll(JsGraphics *gfx, int xdir, int ydir) {
if (xdir==0 && ydir==0) return;
int y;
if (ydir<=0) {
int h = gfx->data.height+xdir;
int h = gfx->data.height+ydir;
for (y=0;y<h;y++)
graphicsFallbackScrollX(gfx, xdir, y-ydir, y);
} else { // >0

10
test_graphics_scroll.js Normal file
View File

@ -0,0 +1,10 @@
g = Graphics.createArrayBuffer(128,64,1);
g.drawString("Hello");
var before = g.buffer.toString();
g.scroll(0,5);
g.scroll(0,-5);
g.scroll(5,0);
g.scroll(-5,0);
var after = g.buffer.toString();
result = before == after;