Skip to content

Commit

Permalink
Prevent use of reserved names in BindAttribLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbarsky committed Apr 17, 2016
1 parent b00c274 commit a67a744
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 5 additions & 1 deletion components/script/dom/webglprogram.rs
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 4 additions & 6 deletions components/script/dom/webglrenderingcontext.rs
Expand Up @@ -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
Expand Down
@@ -1,3 +1,4 @@
[gl-bind-attrib-location-test.html]
type: testharness
expected: CRASH
[WebGL test #6: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL

0 comments on commit a67a744

Please sign in to comment.