mirror of https://github.com/mgba-emu/mgba.git
Qt: Actually bounds check memory block index
This commit is contained in:
parent
5a1e68beba
commit
01e73bc15f
|
@ -207,6 +207,9 @@ void MemoryView::setIndex(int index) {
|
|||
mCore* core = m_controller->thread()->core;
|
||||
const mCoreMemoryBlock* blocks;
|
||||
size_t nBlocks = core->listMemoryBlocks(core, &blocks);
|
||||
if (index < 0 || static_cast<size_t>(index) >= nBlocks) {
|
||||
return;
|
||||
}
|
||||
const mCoreMemoryBlock& info = blocks[index];
|
||||
|
||||
m_region = qMakePair(info.start, info.end);
|
||||
|
@ -221,7 +224,11 @@ void MemoryView::setSegment(int segment) {
|
|||
mCore* core = m_controller->thread()->core;
|
||||
const mCoreMemoryBlock* blocks;
|
||||
size_t nBlocks = core->listMemoryBlocks(core, &blocks);
|
||||
const mCoreMemoryBlock& info = blocks[m_ui.regions->currentIndex()];
|
||||
int index = m_ui.regions->currentIndex();
|
||||
if (index < 0 || static_cast<size_t>(index) >= nBlocks) {
|
||||
return;
|
||||
}
|
||||
const mCoreMemoryBlock& info = blocks[index];
|
||||
|
||||
m_ui.hexfield->setSegment(info.maxSegment < segment ? info.maxSegment : segment);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue