mem: Fix MemChecker unique_ptr type mismatch
authorAndreas Hansson <andreas.hansson@arm.com>
Thu, 26 May 2016 10:56:24 +0000 (11:56 +0100)
committerAndreas Hansson <andreas.hansson@arm.com>
Thu, 26 May 2016 10:56:24 +0000 (11:56 +0100)
This patch fixes the type of the unique_ptr instances, to ensure that
the data that is allocated with new[] is also deleted with
delete[]. The issue was highlighted by ASAN.

Change-Id: I2c5510424959d862a9954d83e728d901bb18d309
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-by: Stephan Diestelhorst <stephan.diestelhorst@arm.com>
src/mem/mem_checker_monitor.cc

index 7c0605ca57f2b13c1c8142fd422c188b8b53b669..971dfc0481f0e127af53e34a6990041a089a9643 100644 (file)
@@ -157,7 +157,7 @@ MemCheckerMonitor::recvTimingReq(PacketPtr pkt)
     unsigned size = pkt->getSize();
     Addr addr = pkt->getAddr();
     bool expects_response = pkt->needsResponse() && !pkt->cacheResponding();
-    std::unique_ptr<uint8_t> pkt_data;
+    std::unique_ptr<uint8_t[]> pkt_data;
     MemCheckerMonitorSenderState* state = NULL;
 
     if (expects_response && is_write) {
@@ -246,7 +246,7 @@ MemCheckerMonitor::recvTimingResp(PacketPtr pkt)
     bool is_failed_LLSC = pkt->isLLSC() && pkt->req->getExtraData() == 0;
     unsigned size = pkt->getSize();
     Addr addr = pkt->getAddr();
-    std::unique_ptr<uint8_t> pkt_data;
+    std::unique_ptr<uint8_t[]> pkt_data;
     MemCheckerMonitorSenderState* received_state = NULL;
 
     if (is_read) {