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.
This commit is contained in:
Oliver Smith 2022-07-31 21:10:08 +02:00 committed by Caleb Connolly
parent fc5f065269
commit a1df67dfce
No known key found for this signature in database
GPG key ID: 0583312B195F64B6

View file

@ -2966,7 +2966,7 @@ static void nsvg__scaleToViewbox(NSVGparser* p, const char* units)
NSVGshape** nsvgGetTextShapes(NSVGimage* image, char* text, int textLen) NSVGshape** nsvgGetTextShapes(NSVGimage* image, char* text, int textLen)
{ {
NSVGshape *shape = NULL; 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; int i;
// make list of paths representing glyphs to render // make list of paths representing glyphs to render