From ef69eba593298b90eb433493470a1ba4c0f1c0bf Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 12 Dec 2021 16:48:07 +0000 Subject: [PATCH] fontstash: ensure new allocated reasons have their memory cleared --- dgl/src/nanovg/fontstash.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dgl/src/nanovg/fontstash.h b/dgl/src/nanovg/fontstash.h index 72569282..cfe1072f 100644 --- a/dgl/src/nanovg/fontstash.h +++ b/dgl/src/nanovg/fontstash.h @@ -907,6 +907,8 @@ static int fons__allocFont(FONScontext* stash) stash->fonts = (FONSfont**)realloc(stash->fonts, sizeof(FONSfont*) * stash->cfonts); if (stash->fonts == NULL) return -1; + for (int i=stash->nfonts; icfonts; ++i) + stash->fonts[i] = NULL; } font = (FONSfont*)malloc(sizeof(FONSfont)); if (font == NULL) goto error; @@ -1015,6 +1017,8 @@ static FONSglyph* fons__allocGlyph(FONSfont* font) font->cglyphs = font->cglyphs == 0 ? 8 : font->cglyphs * 2; font->glyphs = (FONSglyph*)realloc(font->glyphs, sizeof(FONSglyph) * font->cglyphs); if (font->glyphs == NULL) return NULL; + for (int i=font->nglyphs; icglyphs; ++i) + memset(&font->glyphs[i], 0, sizeof(*font->glyphs)); } font->nglyphs++; return &font->glyphs[font->nglyphs-1];