diff options
author | David Zbarsky <dzbarsky@gmail.com> | 2016-04-16 12:05:59 -0700 |
---|---|---|
committer | David Zbarsky <dzbarsky@gmail.com> | 2016-04-17 11:52:40 -0700 |
commit | a67a7440572862df11c5e8e19707cbba6a133a37 (patch) | |
tree | 548bb500120310d83cf42c8fbb9effe38969daea /components/script/dom | |
parent | b00c2740e300fd7b8c18276d8d416a9f78c42674 (diff) | |
download | servo-a67a7440572862df11c5e8e19707cbba6a133a37.tar.gz servo-a67a7440572862df11c5e8e19707cbba6a133a37.zip |
Prevent use of reserved names in BindAttribLocation
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/webglprogram.rs | 6 | ||||
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 10 |
2 files changed, 9 insertions, 7 deletions
diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index d288e9422c4..0458e2ae2ca 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -147,7 +147,7 @@ impl WebGLProgram { } // Check if the name is reserved - if name.starts_with("webgl") || name.starts_with("_webgl_") { + if name.starts_with("gl_") || name.starts_with("webgl") || name.starts_with("_webgl_") { return Err(WebGLError::InvalidOperation); } @@ -185,6 +185,10 @@ impl WebGLProgram { } // Check if the name is reserved + if name.starts_with("gl_") { + return Err(WebGLError::InvalidOperation); + } + if name.starts_with("webgl") || name.starts_with("_webgl_") { return Ok(None); } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 197dcce55f5..5f1b0589af4 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -979,12 +979,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn GetUniformLocation(&self, program: Option<&WebGLProgram>, name: DOMString) -> Option<Root<WebGLUniformLocation>> { - if let Some(program) = program { - handle_potential_webgl_error!(self, program.get_uniform_location(name), None) - .map(|location| WebGLUniformLocation::new(self.global().r(), location, program.id())) - } else { - None - } + program.and_then(|p| { + handle_potential_webgl_error!(self, p.get_uniform_location(name), None) + .map(|location| WebGLUniformLocation::new(self.global().r(), location, p.id())) + }) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 |