aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/devdraw
diff options
context:
space:
mode:
authorXiao-Yong <jinxiaoyong@gmail.com>2019-04-05 12:44:47 -0600
committerRuss Cox <rsc@golang.org>2019-04-05 14:44:47 -0400
commit0308e1f010cd8650840fa0ceee3b342229982420 (patch)
treef7115963afb5857d3fae489b5c43295dfa92d143 /src/cmd/devdraw
parent4d3c36cce4d70dfd88bd5e782e86141775577d30 (diff)
downloadplan9port-0308e1f010cd8650840fa0ceee3b342229982420.tar.gz
plan9port-0308e1f010cd8650840fa0ceee3b342229982420.tar.bz2
plan9port-0308e1f010cd8650840fa0ceee3b342229982420.zip
devdraw: fix cocoa metal _flushmemscreen for invalid rectangles (#240)
It is possible to receive multiple screen resize events, and resizeimg would be called for different sizes, before _flushmemscreen actually gets called with rectangle sizes different from the most recent resizeimg call. The size mismatch would trigger illegal memory access inside _flushmemscreen. This commit protects _flushmemscreen by returning early if the requested rectangle is outside of the current texture rectangle.
Diffstat (limited to 'src/cmd/devdraw')
-rw-r--r--src/cmd/devdraw/cocoa-screen-metal.m4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m
index 21123f16..78110302 100644
--- a/src/cmd/devdraw/cocoa-screen-metal.m
+++ b/src/cmd/devdraw/cocoa-screen-metal.m
@@ -987,6 +987,10 @@ void
_flushmemscreen(Rectangle r)
{
LOG(@"_flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r));
+ if(!rectinrect(r, Rect(0, 0, texture.width, texture.height))){
+ LOG(@"Rectangle is out of bounds, return.");
+ return;
+ }
@autoreleasepool{
[texture