Skip to content

Commit

Permalink
backend: gl: fix use-after-scope
Browse files Browse the repository at this point in the history
'format' was pointing to an array with a shorter lifetime

suggested by @tryone144

Co-authored-by: Bernd Busse <bernd@busse-net.de>
  • Loading branch information
yshui and tryone144 authored Dec 2, 2022
1 parent d38b0ea commit 236c822
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/backend/gl/gl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,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);
Expand Down

0 comments on commit 236c822

Please sign in to comment.