From 121091ec26e40328bfa5a95a68b96504d8dea816 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 5 Jun 2022 13:39:33 +0200 Subject: [PATCH] Fix writing to buffer out of bounds warning (another one) --- libraries/entities/src/EntityItemProperties.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 8461862c4a..294f15c07c 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -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; }