提交 39d61c82 编写于 作者: Z Zihao Yu

emu,ram: add assert() to catch out-of-bound memory accessing

上级 a00e074e
......@@ -95,6 +95,10 @@ void init_ram(const char *img) {
extern "C" void ram_helper(
uint64_t rIdx, uint64_t *rdata, uint64_t wIdx, uint64_t wdata, uint64_t wmask, uint8_t wen) {
assert(rIdx < RAMSIZE / sizeof(uint64_t));
*rdata = ram[rIdx];
if (wen) { ram[wIdx] = (ram[wIdx] & ~wmask) | (wdata & wmask); }
if (wen) {
assert(wIdx < RAMSIZE / sizeof(uint64_t));
ram[wIdx] = (ram[wIdx] & ~wmask) | (wdata & wmask);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册