tvg_loader: guarantee the buffer ends with the null character

the issue is detected by asan.
This commit is contained in:
Hermet Park 2021-08-30 21:21:11 +09:00
parent c0e21bfcee
commit c6becf4ec6

View file

@ -58,8 +58,9 @@ bool TvgLoader::readHeader()
ptr += TVG_HEADER_SIGNATURE_LENGTH;
//2. Version
char version[TVG_HEADER_VERSION_LENGTH];
char version[TVG_HEADER_VERSION_LENGTH + 1];
memcpy(version, ptr, TVG_HEADER_VERSION_LENGTH);
version[TVG_HEADER_VERSION_LENGTH - 1] = '\0';
ptr += TVG_HEADER_VERSION_LENGTH;
this->version = atoi(version);
if (this->version > THORVG_VERSION_NUMBER()) {