Buffer DestroyImpl check for buffer resource to avoid double free

Double free was happening if buffer.Destroy() was called right
before the buffer went out of scope since DestroyImpl wouldn't
check to see if the resource was already released.

Also refactor Destroy in Texture classes to match the pattern
of Buffer classes. Added validation of the texture object when
Destroy is called.

Bug: dawn:124, chromium:947323
Change-Id: I0e4a652ff5b86a151b4919c781c1dd385b4e3213
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6060
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
This commit is contained in:
Natasha Lee
2019-04-01 19:49:04 +00:00
committed by Commit Bot service account
parent 14487c34f7
commit 20b0c33913
12 changed files with 36 additions and 20 deletions

View File

@@ -28,7 +28,7 @@ namespace dawn_native { namespace opengl {
}
Buffer::~Buffer() {
DestroyImpl();
DestroyInternal();
}
GLuint Buffer::GetHandle() const {

View File

@@ -177,7 +177,7 @@ namespace dawn_native { namespace opengl {
}
Texture::~Texture() {
Destroy();
DestroyInternal();
}
void Texture::DestroyImpl() {