mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +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)
|
bool LottieLoader::open(const char* data, uint32_t size, bool copy)
|
||||||
{
|
{
|
||||||
if (copy) {
|
if (copy) {
|
||||||
content = (char*)malloc(size);
|
content = (char*)malloc(size + 1);
|
||||||
if (!content) return false;
|
if (!content) return false;
|
||||||
memcpy((char*)content, data, size);
|
memcpy((char*)content, data, size);
|
||||||
|
const_cast<char*>(content)[size] = '\0';
|
||||||
} else content = data;
|
} else content = data;
|
||||||
|
|
||||||
this->size = size;
|
this->size = size;
|
||||||
|
|
Loading…
Add table
Reference in a new issue