gem5: assert before indexing intro arrays to verify bounds

This commit is contained in:
Ali Saidi
2012-05-10 18:04:27 -05:00
parent 4f66bcdd2e
commit 5745665509
2 changed files with 3 additions and 0 deletions

View 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 |

View 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();