[vlc-devel] [PATCH 2/9] qt: add bound checking to selected setters in SelectableListModel

Pierre Lamot pierre at videolabs.io
Mon Nov 18 18:15:35 CET 2019


---
 modules/gui/qt/components/selectable_list_model.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/gui/qt/components/selectable_list_model.cpp b/modules/gui/qt/components/selectable_list_model.cpp
index cf6711761d..45a2c997ea 100644
--- a/modules/gui/qt/components/selectable_list_model.cpp
+++ b/modules/gui/qt/components/selectable_list_model.cpp
@@ -26,6 +26,9 @@ namespace vlc {
 
 void SelectableListModel::setSelected(int row, bool selected)
 {
+    if (row < 0 || row >= rowCount())
+        return;
+
     setRowSelected(row, selected);
 
     QModelIndex modelIndex = index(row);
@@ -35,11 +38,17 @@ void SelectableListModel::setSelected(int row, bool selected)
 
 bool SelectableListModel::isSelected(int row) const
 {
+    if (row < 0 || row >= rowCount())
+        return false;
+
     return isRowSelected(row);
 }
 
 void SelectableListModel::toggleSelected(int row)
 {
+    if (row < 0 || row >= rowCount())
+        return;
+
     setRowSelected(row, !isRowSelected(row));
 
     QModelIndex modelIndex = index(row);
-- 
2.17.1



More information about the vlc-devel mailing list