From eeecec91b64403da43d6a33ca02f8f391844d597 Mon Sep 17 00:00:00 2001 From: Westerbly Snaydley Date: Thu, 9 Nov 2023 17:41:40 -0300 Subject: [PATCH] fix some samples releasing a null surface texture --- examples/texture_arrays/main.c | 4 +++- examples/triangle/main.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/texture_arrays/main.c b/examples/texture_arrays/main.c index a8ba551b..afb2c36b 100644 --- a/examples/texture_arrays/main.c +++ b/examples/texture_arrays/main.c @@ -667,7 +667,9 @@ int main(int argc, char *argv[]) { case WGPUSurfaceGetCurrentTextureStatus_Outdated: case WGPUSurfaceGetCurrentTextureStatus_Lost: { // Skip this frame, and re-configure surface. - wgpuTextureRelease(surface_texture.texture); + if (surface_texture.texture != NULL) { + wgpuTextureRelease(surface_texture.texture); + } int width, height; glfwGetWindowSize(window, &width, &height); if (width != 0 && height != 0) { diff --git a/examples/triangle/main.c b/examples/triangle/main.c index e6272ead..e82e2ce4 100644 --- a/examples/triangle/main.c +++ b/examples/triangle/main.c @@ -304,7 +304,9 @@ int main(int argc, char *argv[]) { case WGPUSurfaceGetCurrentTextureStatus_Outdated: case WGPUSurfaceGetCurrentTextureStatus_Lost: { // Skip this frame, and re-configure surface. - wgpuTextureRelease(surface_texture.texture); + if (surface_texture.texture != NULL) { + wgpuTextureRelease(surface_texture.texture); + } int width, height; glfwGetWindowSize(window, &width, &height); if (width != 0 && height != 0) {