diff --git a/examples/declarative/modelviews/abstractitemmodel/model.cpp b/examples/declarative/modelviews/abstractitemmodel/model.cpp
index f2397c3380884890858c609e454220be5daf000f..2e4c7e2a156e5373e9cb094be919811ba001506d 100644
--- a/examples/declarative/modelviews/abstractitemmodel/model.cpp
+++ b/examples/declarative/modelviews/abstractitemmodel/model.cpp
@@ -77,7 +77,7 @@ int AnimalModel::rowCount(const QModelIndex & parent) const {
 }
 
 QVariant AnimalModel::data(const QModelIndex & index, int role) const {
-    if (index.row() < 0 || index.row() > m_animals.count())
+    if (index.row() < 0 || index.row() >= m_animals.count())
         return QVariant();
 
     const Animal &animal = m_animals[index.row()];
diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp b/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp
index f2397c3380884890858c609e454220be5daf000f..2e4c7e2a156e5373e9cb094be919811ba001506d 100644
--- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp
+++ b/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp
@@ -77,7 +77,7 @@ int AnimalModel::rowCount(const QModelIndex & parent) const {
 }
 
 QVariant AnimalModel::data(const QModelIndex & index, int role) const {
-    if (index.row() < 0 || index.row() > m_animals.count())
+    if (index.row() < 0 || index.row() >= m_animals.count())
         return QVariant();
 
     const Animal &animal = m_animals[index.row()];