From 4865134cd3b88e0fc2d8b2990f955c5545d9304d Mon Sep 17 00:00:00 2001 From: Eric Price Date: Sun, 15 Aug 2021 12:50:45 +0200 Subject: [PATCH] LP-622 - fix illegal address access to tmp rvalue with a tmp pointer in correct scope --- ground/gcs/src/plugins/flightlog/flightlogmanager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ground/gcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/gcs/src/plugins/flightlog/flightlogmanager.cpp index 02a3b0f55..902893ab0 100644 --- a/ground/gcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/gcs/src/plugins/flightlog/flightlogmanager.cpp @@ -229,13 +229,15 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) // cycle until there is space for another object while (start + header_len + 1 < data_len) { memset(&fields, 0xFF, total_len); - memcpy(&fields, &logEntry->getData().Data[start], header_len); + uint8_t *tmp = logEntry->getData().Data; // avoid compiler warning regarding addressing a temporary make sure tmp lives until after memcpy + memcpy(&fields, &tmp[start], header_len); // check wether a packed object is found // note that empty data blocks are set as 0xFF in flight side to minimize flash wearing // thus as soon as this read outside of used area, the test will fail as lenght would be 0xFFFF quint32 toread = header_len + fields.Size; if (!(toread + start > data_len)) { - memcpy(&fields, &logEntry->getData().Data[start], toread); + uint8_t *tmp = logEntry->getData().Data; // avoid compiler warning regarding addressing a temporary make sure tmp lives until after memcpy + memcpy(&fields, &tmp[start], toread); ExtendedDebugLogEntry *subEntry = new ExtendedDebugLogEntry(); subEntry->setData(fields, m_objectManager); m_logEntries << subEntry;