From a1df67dfce75bebab2da264014ebfa8cc3fc9e30 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 31 Jul 2022 21:10:08 +0200 Subject: [PATCH] nsvgGetTextShapes: fix uninitialized values Use calloc to zero ret, because ret[i] does not get written if NSVG_FLAGS_VISIBLE is unset. Found with valgrind. --- include/nanosvg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nanosvg.h b/include/nanosvg.h index 158c7f2..b175fdf 100644 --- a/include/nanosvg.h +++ b/include/nanosvg.h @@ -2966,7 +2966,7 @@ static void nsvg__scaleToViewbox(NSVGparser* p, const char* units) NSVGshape** nsvgGetTextShapes(NSVGimage* image, char* text, int textLen) { NSVGshape *shape = NULL; - NSVGshape **ret = malloc(sizeof(NSVGshape*)*textLen); // array of paths, text to render + NSVGshape **ret = calloc(textLen, sizeof(shape)); // array of paths, text to render int i; // make list of paths representing glyphs to render