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.
This commit is contained in:
parent
4d3c36cce4
commit
0308e1f010
1 changed files with 4 additions and 0 deletions
|
|
@ -987,6 +987,10 @@ void
|
||||||
_flushmemscreen(Rectangle r)
|
_flushmemscreen(Rectangle r)
|
||||||
{
|
{
|
||||||
LOG(@"_flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(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{
|
@autoreleasepool{
|
||||||
[texture
|
[texture
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue