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.
This commit is contained in:
Eric Anholt 2016-08-13 23:46:25 -07:00
parent 3277c5281c
commit 9a10666941

View file

@ -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)))