Auto merge of #20674 - simartin:issue_20556, r=nox

Issue #20556: Implement proper checks in WebGLRenderingContext's bindBuffer()

Implement missing check, about deleted buffers.
---
- [X] `./mach build -d` does not report any errors
- [X] `./mach build-geckolib` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #20556
- [X] There are tests for these changes

<!-- 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/20674)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-05-18 23:49:37 -04:00 committed by GitHub
commit cb764be7cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 0 deletions

View file

@ -77,6 +77,9 @@ impl WebGLBuffer {
// NB: Only valid buffer targets come here
pub fn bind(&self, target: u32) -> WebGLResult<()> {
if self.is_deleted() || self.is_pending_delete() {
return Err(WebGLError::InvalidOperation);
}
if let Some(previous_target) = self.target.get() {
if target != previous_target {
return Err(WebGLError::InvalidOperation);
@ -141,6 +144,10 @@ impl WebGLBuffer {
self.pending_delete.set(true);
}
pub fn is_pending_delete(&self) -> bool {
self.pending_delete.get()
}
pub fn add_vao_reference(&self, id: WebGLVertexArrayId) {
let mut vao_refs = self.vao_references.borrow_mut();
if let Some(ref mut vao_refs) = *vao_refs {