From b7a56b5895db431f8204ce70feb609988ec6af5b Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Sat, 10 Dec 2022 17:00:28 -0500 Subject: [PATCH] Clean up dangling pointers when freeing glyphmap Partially fixes issue #941. --- src/utf8map.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utf8map.c b/src/utf8map.c index 4748cd618..968876bd6 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -363,6 +363,7 @@ void free_all_glyphmap_u(void) { int glyph; + int x, y; for (glyph = 0; glyph < MAX_GLYPH; ++glyph) { if (glyphmap[glyph].u) { @@ -374,6 +375,12 @@ free_all_glyphmap_u(void) glyphmap[glyph].u = 0; } } + /* Prevent use after free from gg.gbuf */ + for (y = 0; y < ROWNO; ++y) { + for (x = 0; x < COLNO; ++x) { + gg.gbuf[y][x].glyphinfo.gm.u = NULL; + } + } } /* helper routine if a window port wants to embed any UTF-8 sequences