From b2f783b70b6bd4f32a2e82870b3ff9db0db8589e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 20 Jan 2024 13:30:31 -0500 Subject: [PATCH] gl: Avoid a use-after-free This only happens with big, non-atlased glyphs, so it is rare, but it gets triggered by the Masking demo in gtk4-demo. Fixes: #6347 --- gsk/gl/gskgltexturelibrary.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gsk/gl/gskgltexturelibrary.c b/gsk/gl/gskgltexturelibrary.c index c09d2e55f8..c27fcf5fd7 100644 --- a/gsk/gl/gskgltexturelibrary.c +++ b/gsk/gl/gskgltexturelibrary.c @@ -117,9 +117,8 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self, g_hash_table_iter_remove (&iter); dropped++; } - - if (periodic_scan) - entry->accessed = FALSE; + else if (periodic_scan) + entry->accessed = FALSE; } } @@ -440,7 +439,6 @@ gsk_gl_texture_library_pack (GskGLTextureLibrary *self, entry->texture = texture; entry->is_atlased = FALSE; - entry->accessed = TRUE; entry->area.x = padding / (float) (padding + width + padding); entry->area.y = padding / (float) (padding + height + padding); entry->area.x2 = (padding + width) / (float) (padding + width + padding);