gem5: assert before indexing intro arrays to verify bounds
authorAli Saidi <Ali.Saidi@ARM.com>
Thu, 10 May 2012 23:04:27 +0000 (18:04 -0500)
committerAli Saidi <Ali.Saidi@ARM.com>
Thu, 10 May 2012 23:04:27 +0000 (18:04 -0500)
src/dev/arm/gic.cc
src/mem/abstract_mem.cc

index f686c2a135e98b9c81556972ae57d8fb33dd8fbe..94719f86fb90e800961dc18290a2aeed3cf09af0 100644 (file)
@@ -193,10 +193,12 @@ Gic::readDistributor(PacketPtr pkt)
             pkt->set<uint8_t>(int_p[int_num]);
             break;
           case 2:
+            assert((int_num + 1) < (SGI_MAX + PPI_MAX));
             pkt->set<uint16_t>(int_p[int_num] |
                                int_p[int_num+1] << 8);
             break;
           case 4:
+            assert((int_num + 3) < (SGI_MAX + PPI_MAX));
             pkt->set<uint32_t>(int_p[int_num] |
                                int_p[int_num+1] << 8 |
                                int_p[int_num+2] << 16 |
index 13a1183a27da188024323dd0e67d4bfe9c2b4d01..1b28a2319ac32cde28dd9ce06902ba9d1a9a9f93 100644 (file)
@@ -390,6 +390,7 @@ AbstractMemory::functionalAccess(PacketPtr pkt)
     } else if (pkt->isPrint()) {
         Packet::PrintReqState *prs =
             dynamic_cast<Packet::PrintReqState*>(pkt->senderState);
+        assert(prs);
         // Need to call printLabels() explicitly since we're not going
         // through printObj().
         prs->printLabels();