diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 29e8f9b140..0e32ade94d 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -288,9 +288,11 @@ void QMapData::deleteNode(QMapNode *z) template QMapNode *QMapData::findNode(const Key &akey) const { - Node *lb = root()->lowerBound(akey); - if (lb && !qMapLessThanKey(akey, lb->key)) - return lb; + if (Node *r = root()) { + Node *lb = r->lowerBound(akey); + if (lb && !qMapLessThanKey(akey, lb->key)) + return lb; + } return 0; } @@ -307,10 +309,10 @@ void QMapData::nodeRange(const Key &akey, QMapNode **firstNode, } else if (qMapLessThanKey(n->key, akey)) { n = n->rightNode(); } else { - *firstNode = n->leftNode()->lowerBound(akey); + *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : 0; if (!*firstNode) *firstNode = n; - *lastNode = n->rightNode()->upperBound(akey); + *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : 0; if (!*lastNode) *lastNode = l; return;