Skip to content
Permalink
Browse files

webgl: Throw an error on readPixels(width < 0 || height < 0)

Otherwise gleam will try to allocate a negative size area for the
result, and we'll panic with oom.
  • Loading branch information
anholt committed Nov 5, 2016
1 parent 3277c52 commit 9a10666941ea4bbec03205609d1b578a749251c6
Showing with 4 additions and 0 deletions.
  1. +4 −0 components/script/dom/webglrenderingcontext.rs
@@ -1777,6 +1777,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
_ => return Ok(self.webgl_error(InvalidOperation)),
}

if width < 0 || height < 0 {
return Ok(self.webgl_error(InvalidValue));
}

let (sender, receiver) = ipc::channel().unwrap();
self.ipc_renderer
.send(CanvasMsg::WebGL(WebGLCommand::ReadPixels(x, y, width, height, format, pixel_type, sender)))

0 comments on commit 9a10666

Please sign in to comment.
You can’t perform that action at this time.