1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(core): avoid using stack allocated memory past end of scope

tox_file_send was using a pointer to memory that was out of scope. Extend
lifetime of avatarHash to avoid this.
This commit is contained in:
Anthony Bilinski 2019-11-25 13:45:08 -08:00
parent 1f80173b2d
commit 9b23abc6de
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -95,9 +95,9 @@ void CoreFile::sendAvatarFile(uint32_t friendId, const QByteArray& data)
uint8_t *file_id = nullptr;
uint8_t *file_name = nullptr;
size_t nameLength = 0;
uint8_t avatarHash[TOX_HASH_LENGTH];
if (!data.isEmpty()) {
static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH, "TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!");
uint8_t avatarHash[TOX_HASH_LENGTH];
tox_hash(avatarHash, (uint8_t*)data.data(), data.size());
filesize = data.size();
file_id = avatarHash;