mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix: fixed segfault after accepting group invite
Fix #4327 Description: - QString::arg call with mulpiple arguments replaced with chained QString::arg calls; - dynamic memory allocation for array of names replaced with allocation on the stack, unfortunately I do not notice this while making Core refactoring. Also code style is formatted with script
This commit is contained in:
parent
6de129fef1
commit
532e05cb0f
|
@ -535,7 +535,7 @@ void Core::onGroupNamelistChange(Tox*, uint32_t groupId, uint32_t peerId,
|
|||
CoreAV::invalidateGroupCallPeerSource(groupId, peerId);
|
||||
}
|
||||
|
||||
qDebug() << QString("Group namelist change %1:%2 %3").arg(groupId, peerId, change);
|
||||
qDebug() << QString("Group namelist change %1:%2 %3").arg(groupId).arg(peerId).arg(change);
|
||||
emit static_cast<Core*>(core)->groupNamelistChanged(groupId, peerId, change);
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ QByteArray Core::getToxSaveData()
|
|||
} \
|
||||
\
|
||||
delete[] prop; \
|
||||
}\
|
||||
}
|
||||
|
||||
void Core::loadFriends()
|
||||
{
|
||||
|
@ -1171,10 +1171,7 @@ QStringList Core::getGroupPeerNames(int groupId) const
|
|||
return {};
|
||||
}
|
||||
|
||||
std::vector<uint8_t*> namesArray(nPeers, new uint8_t[TOX_MAX_NAME_LENGTH]);
|
||||
std::vector<size_t> lengths(nPeers);
|
||||
TOX_ERR_CONFERENCE_PEER_QUERY error;
|
||||
|
||||
uint32_t count = tox_conference_peer_count(tox, groupId, &error);
|
||||
if (!parsePeerQueryError(error)) {
|
||||
return {};
|
||||
|
@ -1187,17 +1184,14 @@ QStringList Core::getGroupPeerNames(int groupId) const
|
|||
|
||||
QStringList names;
|
||||
for (uint32_t i = 0; i < nPeers; ++i) {
|
||||
lengths[i] = tox_conference_peer_get_name_size(tox, groupId, i, &error);
|
||||
bool ok = tox_conference_peer_get_name(tox, groupId, i, namesArray[i], &error);
|
||||
if (parsePeerQueryError(error) && ok) {
|
||||
names.append(ToxString(namesArray[i], lengths[i]).getQString());
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH] = {0};
|
||||
size_t length = tox_conference_peer_get_name_size(tox, groupId, i, &error);
|
||||
bool ok = tox_conference_peer_get_name(tox, groupId, i, name, &error);
|
||||
if (ok && parsePeerQueryError(error)) {
|
||||
names.append(ToxString(name, length).getQString());
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8_t* name : namesArray) {
|
||||
delete[] name;
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user