Fix off by one error.
Change-Id: I18a2d177f3212626b7091150f42dfe151e47570e
This commit is contained in:
parent
33eb652783
commit
9c36a99ebc
2 changed files with 8 additions and 1 deletions
|
@ -41,7 +41,7 @@ struct RegsInfo {
|
|||
}
|
||||
|
||||
inline AddressType* Save(uint32_t reg) {
|
||||
if (reg > MAX_REGISTERS) {
|
||||
if (reg >= MAX_REGISTERS) {
|
||||
// This should never happen since all currently supported
|
||||
// architectures have < 64 total registers.
|
||||
abort();
|
||||
|
|
|
@ -82,4 +82,11 @@ TEST(RegsInfoTest, all) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(RegsInfoTest, invalid_register) {
|
||||
RegsImplFake<uint64_t> regs(64);
|
||||
RegsInfo<uint64_t> info(®s);
|
||||
|
||||
EXPECT_DEATH(info.Save(RegsInfo<uint64_t>::MAX_REGISTERS), "");
|
||||
}
|
||||
|
||||
} // namespace unwindstack
|
||||
|
|
Loading…
Reference in a new issue