diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-01-29 01:45:54 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-01-29 01:45:54 (GMT) |
commit | 687d50f05a1a2d9355f0990e845967930c57b985 (patch) | |
tree | 3971c928403d1439b743c0d3789911e498b3d8ce /src | |
parent | c0160230c4fd6f226d0c5ddabe3762f5fa855768 (diff) | |
download | Qt-687d50f05a1a2d9355f0990e845967930c57b985.zip Qt-687d50f05a1a2d9355f0990e845967930c57b985.tar.gz Qt-687d50f05a1a2d9355f0990e845967930c57b985.tar.bz2 |
Don't crash when accessing index -1
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index e975a5f..8c70539 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -405,7 +405,7 @@ QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const { checkRoles(); QHash<int, QVariant> rv; - if (index >= count()) + if (index >= count() || index < 0) return rv; ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); @@ -430,7 +430,7 @@ QVariant QmlListModel::data(int index, int role) const { checkRoles(); QVariant rv; - if (index >= count()) + if (index >= count() || index < 0) return rv; ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); @@ -643,7 +643,7 @@ void QmlListModel::append(const QScriptValue& valuemap) */ QScriptValue QmlListModel::get(int index) const { - if (index >= count()) { + if (index >= count() || index < 0) { qmlInfo(this) << tr("get: index %1 out of range").arg(index); return 0; } @@ -680,7 +680,7 @@ void QmlListModel::set(int index, const QScriptValue& valuemap) qmlInfo(this) << tr("set: value is not an object"); return; } - if ( !_root || index > _root->values.count()) { + if ( !_root || index > _root->values.count() || index < 0) { qmlInfo(this) << tr("set: index %1 out of range").arg(index); return; } @@ -719,7 +719,7 @@ void QmlListModel::set(int index, const QScriptValue& valuemap) */ void QmlListModel::setProperty(int index, const QString& property, const QVariant& value) { - if ( !_root || index >= _root->values.count()) { + if ( !_root || index >= _root->values.count() || index < 0) { qmlInfo(this) << tr("set: index %1 out of range").arg(index); return; } |