Skip to content

Commit

Permalink
TriageView Check for valid indexes before navigating to them
Browse files Browse the repository at this point in the history
  • Loading branch information
plafosse committed Dec 2, 2023
1 parent 9393d71 commit c5e9fd5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/triage/exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ QVariant GenericExportsModel::data(const QModelIndex& index, int role) const
case Qt::DisplayRole:
if (role != Qt::DisplayRole)
return QVariant();
if (index.row() >= (int)m_entries.size())
if (!index.isValid() || index.row() >= (int)m_entries.size())
return QVariant();
if (index.column() == AddressColumn)
return QString("0x") + QString::number(m_entries[index.row()]->GetAddress(), 16);
Expand Down Expand Up @@ -155,7 +155,7 @@ QModelIndex GenericExportsModel::parent(const QModelIndex&) const

SymbolRef GenericExportsModel::getSymbol(const QModelIndex& index)
{
if (index.row() >= (int)m_entries.size())
if (!index.isValid() || index.row() >= (int)m_entries.size())
return nullptr;
return m_entries[index.row()];
}
Expand Down
4 changes: 2 additions & 2 deletions examples/triage/imports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ QVariant GenericImportsModel::data(const QModelIndex& index, int role) const
switch (role)
{
case Qt::DisplayRole:
if (index.row() >= (int)m_entries.size())
if (!index.isValid() || index.row() >= (int)m_entries.size())
return QVariant();
if (index.column() == 0)
return QString("0x") + QString::number(m_entries[index.row()]->GetAddress(), 16);
Expand Down Expand Up @@ -122,7 +122,7 @@ QModelIndex GenericImportsModel::parent(const QModelIndex&) const

SymbolRef GenericImportsModel::getSymbol(const QModelIndex& index)
{
if (index.row() >= (int)m_entries.size())
if (!index.isValid() || index.row() >= (int)m_entries.size())
return nullptr;
return m_entries[index.row()];
}
Expand Down
4 changes: 2 additions & 2 deletions examples/triage/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ QVariant GenericStringsModel::data(const QModelIndex& index, int role) const
switch (role)
{
case Qt::DisplayRole:
if (index.row() >= (int)m_entries.size())
if (!index.isValid() || index.row() >= (int)m_entries.size())
return QVariant();
if (index.column() == 0)
return QString("0x") + QString::number(m_entries[index.row()].start, 16);
Expand Down Expand Up @@ -115,7 +115,7 @@ QString GenericStringsModel::stringRefToQString(const BNStringReference& stringR

BNStringReference GenericStringsModel::getStringRefAt(const QModelIndex& index) const
{
if (index.row() >= (int)m_entries.size())
if (!index.isValid() || index.row() >= (int)m_entries.size())
return BNStringReference{};
return m_entries[index.row()];
}
Expand Down

0 comments on commit c5e9fd5

Please sign in to comment.