From bc1f99f2aec56bf47732ac4ef016430d4447f497 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 2 Dec 2022 02:57:28 +0000 Subject: [PATCH] backend: gl: fix use-after-scope 'format' was pointing to an array with a shorter lifetime suggested by @tryone144 Co-authored-by: Bernd Busse --- src/backend/gl/gl_common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index 9f9ec3b..ea08cd2 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -925,10 +925,8 @@ bool gl_init(struct gl_data *gd, session_t *ps) { // Set up the size and format of the back texture glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gd->back_fbo); glDrawBuffer(GL_COLOR_ATTACHMENT0); - const GLint *format = (const GLint[]){GL_RGB8, GL_RGBA8}; - if (gd->dithered_present) { - format = (const GLint[]){GL_RGB16, GL_RGBA16}; - } + const GLint *format = gd->dithered_present ? (const GLint[]){GL_RGB16, GL_RGBA16} + : (const GLint[]){GL_RGB8, GL_RGBA8}; for (int i = 0; i < 2; i++) { gd->back_format = format[i]; gl_resize(gd, ps->root_width, ps->root_height);