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

fix(settings): prevent signed overflow and associated warning

This commit is contained in:
sudden6 2017-10-18 17:31:35 +02:00
parent 2f13796acc
commit 6d1b1f62ab
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -262,7 +262,9 @@ void SettingsSerializer::save()
QDataStream stream(&data, QIODevice::ReadWrite | QIODevice::Append); QDataStream stream(&data, QIODevice::ReadWrite | QIODevice::Append);
stream.setVersion(QDataStream::Qt_5_0); stream.setVersion(QDataStream::Qt_5_0);
for (int g = -1; g < groups.size(); ++g) { // prevent signed overflow and the associated warning
int numGroups = std::max(0, groups.size());
for (int g = -1; g < numGroups; ++g) {
// Save the group name, if any // Save the group name, if any
if (g != -1) { if (g != -1) {
writeStream(stream, RecordTag::GroupStart); writeStream(stream, RecordTag::GroupStart);