From 99d1a38918fcb5ce97f9c6d10a794fe6e224860d Mon Sep 17 00:00:00 2001 From: Mis012 Date: Sun, 8 Jun 2025 13:43:52 +0200 Subject: [PATCH] EGLImpl: fix crash when eglDestroySurface is passed EGL_NO_SURFACE --- .../egl/com_google_android_gles_jni_EGLImpl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api-impl-jni/egl/com_google_android_gles_jni_EGLImpl.c b/src/api-impl-jni/egl/com_google_android_gles_jni_EGLImpl.c index 9b9131e6..6d560e73 100644 --- a/src/api-impl-jni/egl/com_google_android_gles_jni_EGLImpl.c +++ b/src/api-impl-jni/egl/com_google_android_gles_jni_EGLImpl.c @@ -114,9 +114,11 @@ JNIEXPORT jboolean JNICALL Java_com_google_android_gles_1jni_EGLImpl_native_1egl { struct ANativeWindow *native_window = g_hash_table_lookup(egl_surface_hashtable, _PTR(surface)); - bool ret = eglDestroySurface(_PTR(display), _PTR(surface)); - /* ANativeWindow_fromSurface starts the refcounter at 1, so this will destroy the native window */ - ANativeWindow_release(native_window); + EGLBoolean ret = eglDestroySurface(_PTR(display), _PTR(surface)); + if (ret) { + /* ANativeWindow_fromSurface starts the refcounter at 1, so this will destroy the native window */ + ANativeWindow_release(native_window); + } return ret; }