mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
webgl: Fix validation of drawElements()'s type argument.
Fixes crash due to unexpected GL errors in gl-drawelements.html.
This commit is contained in:
parent
9b4713f536
commit
15fa1a5a7d
2 changed files with 5 additions and 6 deletions
|
@ -1165,10 +1165,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
|
||||||
fn DrawElements(&self, mode: u32, count: i32, type_: u32, offset: i64) {
|
fn DrawElements(&self, mode: u32, count: i32, type_: u32, offset: i64) {
|
||||||
|
// From the GLES 2.0.25 spec, page 21:
|
||||||
|
//
|
||||||
|
// "type must be one of UNSIGNED_BYTE or UNSIGNED_SHORT"
|
||||||
let type_size = match type_ {
|
let type_size = match type_ {
|
||||||
constants::BYTE | constants::UNSIGNED_BYTE => 1,
|
constants::UNSIGNED_BYTE => 1,
|
||||||
constants::SHORT | constants::UNSIGNED_SHORT => 2,
|
constants::UNSIGNED_SHORT => 2,
|
||||||
constants::INT | constants::UNSIGNED_INT | constants::FLOAT => 4,
|
|
||||||
_ => return self.webgl_error(InvalidEnum),
|
_ => return self.webgl_error(InvalidEnum),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[gl-drawelements.html]
|
|
||||||
type: testharness
|
|
||||||
expected: CRASH
|
|
Loading…
Add table
Add a link
Reference in a new issue