Skip to content
Snippets Groups Projects
Commit bbc08021 authored by Emmanuel Lepage Vallée's avatar Emmanuel Lepage Vallée Committed by Stepan Salenikovich
Browse files

callmodel: Prevent out of bound access


Also adopt an exit early code style to make it more readable.

Change-Id: I51333e202244fbf14769507696ffae0c3807cc2b
Reviewed-by: default avatarStepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
parent 4697a94a
No related branches found
No related tags found
No related merge requests found
...@@ -992,12 +992,17 @@ QModelIndex CallModel::parent( const QModelIndex& idx) const ...@@ -992,12 +992,17 @@ QModelIndex CallModel::parent( const QModelIndex& idx) const
///Get the call index at row,column (active call only) ///Get the call index at row,column (active call only)
QModelIndex CallModel::index( int row, int column, const QModelIndex& parentIdx) const QModelIndex CallModel::index( int row, int column, const QModelIndex& parentIdx) const
{ {
if (row >= 0 && !parentIdx.isValid() && d_ptr->m_lInternalModel.size() > row) { if (row >= 0 && !parentIdx.isValid() && d_ptr->m_lInternalModel.size() > row)
return createIndex(row,column,d_ptr->m_lInternalModel[row]); return createIndex(row,column,d_ptr->m_lInternalModel[row]);
}
else if (row >= 0 && parentIdx.isValid() && d_ptr->m_lInternalModel[parentIdx.row()]->m_lChildren.size() > row) { if (!parentIdx.isValid())
return {};
if (row < 0 || parentIdx.row() >= d_ptr->m_lInternalModel.size())
return {};
if (d_ptr->m_lInternalModel[parentIdx.row()]->m_lChildren.size() > row)
return createIndex(row,column,d_ptr->m_lInternalModel[parentIdx.row()]->m_lChildren[row]); return createIndex(row,column,d_ptr->m_lInternalModel[parentIdx.row()]->m_lChildren[row]);
}
return QModelIndex(); return QModelIndex();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment