aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-14 18:45:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-30 10:38:48 +0200
commit67a101af142355a0ca7cdc234b7ee1716a25d87c (patch)
tree1e0c99bdd9667d24e71075192d8616a3f9c2f4c4 /src
parent9ba195479ac3bc2c64d43ecf26f8c97e65483a5c (diff)
Fix potential null pointer dereferencing
These were found by http://www.viva64.com/en/b/025 most issues are rather cosmetic. Change-Id: I7cc12610aae6a43d26bedb9b480863c0695ddfa3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/particles/qquickitemparticle.cpp1
-rw-r--r--src/qml/qml/qqmlimport.cpp16
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp5
-rw-r--r--src/quick/items/qquickmousearea.cpp2
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp2
-rw-r--r--src/quick/util/qquickpixmapcache.cpp2
6 files changed, 17 insertions, 11 deletions
diff --git a/src/particles/qquickitemparticle.cpp b/src/particles/qquickitemparticle.cpp
index 0fe0b2ae0b..1f357df20d 100644
--- a/src/particles/qquickitemparticle.cpp
+++ b/src/particles/qquickitemparticle.cpp
@@ -163,6 +163,7 @@ void QQuickItemParticle::tick(int time)
m_deletables.clear();
foreach (QQuickParticleData* d, m_loadables){
+ Q_ASSERT(d);
if (m_stasis.contains(d->delegate))
qWarning() << "Current model particles prefers overwrite:false";
//remove old item from the particle that is dying to make room for this one
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 5799886faa..bde61dca9d 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1851,17 +1851,21 @@ bool QQmlImportDatabase::registerPluginTypes(QObject *instance, const QString &b
// This is an 'identified' module
if (typeNamespace != uri) {
// The namespace for type registrations must match the URI for locating the module
- QQmlError error;
- error.setDescription(tr("Module namespace '%1' does not match import URI '%2'").arg(typeNamespace).arg(uri));
- errors->prepend(error);
+ if (errors) {
+ QQmlError error;
+ error.setDescription(tr("Module namespace '%1' does not match import URI '%2'").arg(typeNamespace).arg(uri));
+ errors->prepend(error);
+ }
return false;
}
if (QQmlMetaType::namespaceContainsRegistrations(typeNamespace)) {
// Other modules have already installed to this namespace
- QQmlError error;
- error.setDescription(tr("Namespace '%1' has already been used for type registration").arg(typeNamespace));
- errors->prepend(error);
+ if (errors) {
+ QQmlError error;
+ error.setDescription(tr("Namespace '%1' has already been used for type registration").arg(typeNamespace));
+ errors->prepend(error);
+ }
return false;
} else {
QQmlMetaType::protectNamespace(typeNamespace);
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index d0d6839bdc..a7db7d214e 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -980,12 +980,13 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx)
QQmlEngine *engine = v8engine->engine();
QQmlContextData *context = v8engine->callingContext();
+ Q_ASSERT(context);
QQmlContext *effectiveContext = 0;
if (context->isPragmaLibraryContext)
effectiveContext = engine->rootContext();
else
effectiveContext = context->asQQmlContext();
- Q_ASSERT(context && effectiveContext);
+ Q_ASSERT(effectiveContext);
QString qml = ctx->callData->args[0].toQStringNoThrow();
if (qml.isEmpty())
@@ -1086,10 +1087,10 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx)
QQmlEngine *engine = v8engine->engine();
QQmlContextData *context = v8engine->callingContext();
+ Q_ASSERT(context);
QQmlContextData *effectiveContext = context;
if (context->isPragmaLibraryContext)
effectiveContext = 0;
- Q_ASSERT(context);
QString arg = ctx->callData->args[0].toQStringNoThrow();
if (arg.isEmpty())
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index baa48291e2..d4b64ea75a 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -894,7 +894,7 @@ bool QQuickMouseArea::sendMouseEvent(QMouseEvent *event)
default:
break;
}
- grabber = c->mouseGrabberItem();
+ grabber = c ? c->mouseGrabberItem() : 0;
if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
grabMouse();
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index c20559454e..ee31c018af 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -844,7 +844,7 @@ bool QQuickMultiPointTouchArea::sendMouseEvent(QMouseEvent *event)
default:
break;
}
- grabber = c->mouseGrabberItem();
+ grabber = c ? c->mouseGrabberItem() : 0;
if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
grabMouse();
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index a7f9174219..a5a56949e6 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -805,7 +805,7 @@ void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data)
if (!m_lastUnreferencedPixmap)
m_lastUnreferencedPixmap = data;
- shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit
+ shrinkCache(-1); // Shrink the cache in case it has become larger than cache_limit
if (m_timerId == -1 && m_unreferencedPixmaps && !m_destroying)
m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000);