From 738f8f745a57c1992732c4164459c83e187facf7 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sat, 17 Aug 2024 13:19:21 +0900 Subject: [PATCH] lottie: ensure a null terminator at the end of the copied data In certain cases, the user might want to set mapped memory directly. This update ensures that a null terminator is appended to the string data. Co-Authored-By: Mira Grudzinska Issue: https://github.com/thorvg/thorvg/issues/2642 --- src/loaders/lottie/tvgLottieLoader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/loaders/lottie/tvgLottieLoader.cpp b/src/loaders/lottie/tvgLottieLoader.cpp index d927b7c0..37314f42 100644 --- a/src/loaders/lottie/tvgLottieLoader.cpp +++ b/src/loaders/lottie/tvgLottieLoader.cpp @@ -186,9 +186,10 @@ bool LottieLoader::header() bool LottieLoader::open(const char* data, uint32_t size, bool copy) { if (copy) { - content = (char*)malloc(size); + content = (char*)malloc(size + 1); if (!content) return false; memcpy((char*)content, data, size); + const_cast(content)[size] = '\0'; } else content = data; this->size = size;