From bfe668c7efa65df7d62d095835bac924ae86054f Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 23 Dec 2022 16:38:53 -0500 Subject: [PATCH] memory not freed Reported directly by feedback form. Changes from a recent pull request resulted in more array entries than MAX_GLYPH, so the for loop in free_glyphid_cache() wasn't going far enough, leaving some dupstr() strings unfreed. --- src/utf8map.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utf8map.c b/src/utf8map.c index 55f310341..ec4b24624 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -371,14 +371,14 @@ init_glyph_cache(void) void free_glyphid_cache(void) { - int glyph; + size_t idx; if (!glyphid_cache) return; - for (glyph = 0; glyph < MAX_GLYPH; ++glyph) { - if (glyphid_cache[glyph].id) { - free(glyphid_cache[glyph].id); - glyphid_cache[glyph].id = (char *) 0; + for (idx = 0; idx < glyphid_cache_size; ++idx) { + if (glyphid_cache[idx].id) { + free(glyphid_cache[idx].id); + glyphid_cache[idx].id = (char *) 0; } } free(glyphid_cache);