3
0
Fork 0
mirror of https://github.com/JulianGro/overte.git synced 2025-04-13 01:42:44 +02:00

Fix writing to buffer out of bounds warning (another one)

This commit is contained in:
Dale Glass 2022-06-05 13:39:33 +02:00
parent c4c69f09ee
commit 121091ec26

View file

@ -3992,22 +3992,14 @@ bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityIt
}
bool EntityItemProperties::encodeCloneEntityMessage(const EntityItemID& entityIDToClone, const EntityItemID& newEntityID, QByteArray& buffer) {
char* copyAt = buffer.data();
int outputLength = 0;
if (buffer.size() < (int)(NUM_BYTES_RFC4122_UUID * 2)) {
qCDebug(entities) << "ERROR - encodeCloneEntityMessage() called with buffer that is too small!";
return false;
}
memcpy(copyAt, entityIDToClone.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
copyAt += NUM_BYTES_RFC4122_UUID;
outputLength += NUM_BYTES_RFC4122_UUID;
memcpy(copyAt, newEntityID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
outputLength += NUM_BYTES_RFC4122_UUID;
buffer.resize(outputLength);
buffer.resize(0);
buffer.append(entityIDToClone.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
buffer.append(newEntityID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
return true;
}