mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Fix writing to buffer out of bounds warning (another one)
This commit is contained in:
parent
c4c69f09ee
commit
121091ec26
1 changed files with 3 additions and 11 deletions
|
@ -3992,22 +3992,14 @@ bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityIt
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityItemProperties::encodeCloneEntityMessage(const EntityItemID& entityIDToClone, const EntityItemID& newEntityID, QByteArray& buffer) {
|
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)) {
|
if (buffer.size() < (int)(NUM_BYTES_RFC4122_UUID * 2)) {
|
||||||
qCDebug(entities) << "ERROR - encodeCloneEntityMessage() called with buffer that is too small!";
|
qCDebug(entities) << "ERROR - encodeCloneEntityMessage() called with buffer that is too small!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(copyAt, entityIDToClone.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
buffer.resize(0);
|
||||||
copyAt += NUM_BYTES_RFC4122_UUID;
|
buffer.append(entityIDToClone.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
||||||
outputLength += NUM_BYTES_RFC4122_UUID;
|
buffer.append(newEntityID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
||||||
|
|
||||||
memcpy(copyAt, newEntityID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
|
||||||
outputLength += NUM_BYTES_RFC4122_UUID;
|
|
||||||
|
|
||||||
buffer.resize(outputLength);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue