aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-08-28 20:10:47 -0500
committerGitHub <noreply@github.com>2016-08-28 20:10:47 -0500
commit11e8e42fd855c1078364c70926dfb1c888bdb7bb (patch)
treec57e67a7a36dc0c3ec63cae5204b8d689b20ee06 /components/script/dom/webglrenderingcontext.rs
parent07b770b829c7148d3a10e7a7467e114bc2f23125 (diff)
parentb8b74e4b37dd9488ddef6362098aa45b5d6d3a3c (diff)
downloadservo-11e8e42fd855c1078364c70926dfb1c888bdb7bb.tar.gz
servo-11e8e42fd855c1078364c70926dfb1c888bdb7bb.zip
Auto merge of #13060 - anholt:webgl-invalid-passed-params, r=emilio
webgl: Do validation of glScissor/glViewport(width, height) on the DOM side <!-- Please describe your changes on the following line: --> webgl: Do validation of glScissor/glViewport(width, height) on the DOM side --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Avoids testcase CRASHes due to unexpected GL errors. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13060) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 7814296c38a..d20e55429c4 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -1526,6 +1526,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4
fn Scissor(&self, x: i32, y: i32, width: i32, height: i32) {
+ if width < 0 || height < 0 {
+ return self.webgl_error(InvalidValue)
+ }
+
self.ipc_renderer
.send(CanvasMsg::WebGL(WebGLCommand::Scissor(x, y, width, height)))
.unwrap()
@@ -1938,6 +1942,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4
fn Viewport(&self, x: i32, y: i32, width: i32, height: i32) {
+ if width < 0 || height < 0 {
+ return self.webgl_error(InvalidValue)
+ }
+
self.ipc_renderer
.send(CanvasMsg::WebGL(WebGLCommand::Viewport(x, y, width, height)))
.unwrap()