mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
tvg_loader: guarantee the buffer ends with the null character
the issue is detected by asan.
This commit is contained in:
parent
c0e21bfcee
commit
c6becf4ec6
1 changed files with 2 additions and 1 deletions
|
@ -58,8 +58,9 @@ bool TvgLoader::readHeader()
|
||||||
ptr += TVG_HEADER_SIGNATURE_LENGTH;
|
ptr += TVG_HEADER_SIGNATURE_LENGTH;
|
||||||
|
|
||||||
//2. Version
|
//2. Version
|
||||||
char version[TVG_HEADER_VERSION_LENGTH];
|
char version[TVG_HEADER_VERSION_LENGTH + 1];
|
||||||
memcpy(version, ptr, TVG_HEADER_VERSION_LENGTH);
|
memcpy(version, ptr, TVG_HEADER_VERSION_LENGTH);
|
||||||
|
version[TVG_HEADER_VERSION_LENGTH - 1] = '\0';
|
||||||
ptr += TVG_HEADER_VERSION_LENGTH;
|
ptr += TVG_HEADER_VERSION_LENGTH;
|
||||||
this->version = atoi(version);
|
this->version = atoi(version);
|
||||||
if (this->version > THORVG_VERSION_NUMBER()) {
|
if (this->version > THORVG_VERSION_NUMBER()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue