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:
parent
1f80173b2d
commit
9b23abc6de
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user