From 46619573e0f9ec8e85d5a1882dfe171a5edfb0ac Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sat, 24 Feb 2024 21:35:04 +0100 Subject: [PATCH] egl: Make sure GError gets set when we return FALSE The convention is that when a function returns FALSE or NULL, the error will be set. In this file we call set_egl_error but it might not set an error. Code of the form if (egl_do_thing (..., &error)) use_error (error); will crash in those cases. This commit makes sure we always set the error even if EGL doesn't give us an error. Part-of: --- src/backends/meta-egl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-egl.c b/src/backends/meta-egl.c index ac19828c4..fefba7c67 100644 --- a/src/backends/meta-egl.c +++ b/src/backends/meta-egl.c @@ -158,7 +158,10 @@ set_egl_error (GError **error) error_number = eglGetError (); if (error_number == EGL_SUCCESS) - return; + { + g_warning ("Expected an EGL error but eglGetError returned EGL_SUCCESS"); + error_number = -1; + } error_str = get_egl_error_str (error_number); g_set_error_literal (error, META_EGL_ERROR,