From 945a4c69b3d95c9a5f33aaeeadf12ee93daa9f80 Mon Sep 17 00:00:00 2001 From: spartan-engi Date: Sat, 27 Jul 2024 16:30:49 -0300 Subject: [PATCH] fix buffer overflow on loading .svg file append NULL character to the end of LoadFileData() character stream --- src/rtextures.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rtextures.c b/src/rtextures.c index 60ce58f4b..1be9e829c 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -353,6 +353,14 @@ Image LoadImageSvg(const char *fileNameOrString, int width, int height) { fileData = LoadFileData(fileNameOrString, &dataSize); isSvgStringValid = true; + + // make sure that fileData is a NULL terminated String + // as required by nsvgParse() + if (fileData[dataSize-1] != '\0') + { + fileData = RL_REALLOC(fileData, dataSize+1); + fileData[dataSize] = '\0'; + } } else {