mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
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:
parent
2a342a5463
commit
738f8f745a
1 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue