Skip to content

Commit

Permalink
webgl: Throw an error on readPixels(width < 0 || height < 0)
Browse files Browse the repository at this point in the history
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 9a10666
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/script/dom/webglrenderingcontext.rs
Expand Up @@ -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)))
Expand Down

0 comments on commit 9a10666

Please sign in to comment.