From 168fdb5a91aeddcfb9e65e081f3517ee420608ce Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 22 Aug 2022 15:46:42 -0400 Subject: [PATCH] egl: Move an error check earlier in EGL_BUFFER_AGE_EXT query I can't think of any good reason to call down to the driver and _then_ check whether your calling context was already bad. Reviewed-by: Eric Engestrom Reviewed-by: Daniel Stone Part-of: --- src/egl/main/eglsurface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 9167b9b..ae356e8 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -559,14 +559,14 @@ _eglQuerySurface(_EGLDisplay *disp, _EGLSurface *surface, return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); _EGLContext *ctx = _eglGetCurrentContext(); - EGLint result = disp->Driver->QueryBufferAge(disp, surface); - /* error happened */ - if (result < 0) - return EGL_FALSE; if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || ctx->DrawSurface != surface) return _eglError(EGL_BAD_SURFACE, "eglQuerySurface"); + EGLint result = disp->Driver->QueryBufferAge(disp, surface); + if (result < 0) + return EGL_FALSE; + *value = result; surface->BufferAgeRead = EGL_TRUE; break; -- 2.7.4