all repos — mgba @ bcb1617a6996445faad0f5dede50bbd4d8d6f0b5

mGBA Game Boy Advance Emulator

Qt: Fix out of bounds indices in InputModel
Vicki Pfau vi@endrift.com
Wed, 12 Jul 2017 19:22:34 -0700
commit

bcb1617a6996445faad0f5dede50bbd4d8d6f0b5

parent

1de4c8dc2e4243b07f7de5aef7aecc3a4b90f552

1 files changed, 6 insertions(+), 0 deletions(-)

jump to
M src/platform/qt/input/InputModel.cppsrc/platform/qt/input/InputModel.cpp

@@ -120,7 +120,13 @@

QModelIndex InputModel::index(int row, int column, const QModelIndex& parent) const { if (parent.isValid()) { InputModelItem* p = static_cast<InputModelItem*>(parent.internalPointer()); + if (row >= m_tree[p->obj].count()) { + return QModelIndex(); + } return createIndex(row, column, const_cast<InputModelItem*>(&m_tree[p->obj][row])); + } + if (row >= m_topLevelMenus.count()) { + return QModelIndex(); } return createIndex(row, column, const_cast<InputModelItem*>(&m_topLevelMenus[row])); }