Clean up dangling pointers when freeing glyphmap

Partially fixes issue #941.
This commit is contained in:
Ray Chason
2022-12-10 17:00:28 -05:00
parent 6a1f875b17
commit b7a56b5895
+7
View File
@@ -363,6 +363,7 @@ void
free_all_glyphmap_u(void) free_all_glyphmap_u(void)
{ {
int glyph; int glyph;
int x, y;
for (glyph = 0; glyph < MAX_GLYPH; ++glyph) { for (glyph = 0; glyph < MAX_GLYPH; ++glyph) {
if (glyphmap[glyph].u) { if (glyphmap[glyph].u) {
@@ -374,6 +375,12 @@ free_all_glyphmap_u(void)
glyphmap[glyph].u = 0; 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 /* helper routine if a window port wants to embed any UTF-8 sequences