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 <mira@lottiefiles.com>

Issue: https://github.com/thorvg/thorvg/issues/2642
This commit is contained in:
Hermet Park 2024-08-17 13:19:21 +09:00
parent 2a342a5463
commit 738f8f745a

View file

@ -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<char*>(content)[size] = '\0';
} else content = data;
this->size = size;