From b69ab6c80df6d6befb183a756f6af4e54faedcbd Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Feb 2015 12:56:12 -0800 Subject: [PATCH] verify NodeList has a linkedData before using it --- libraries/networking/src/LimitedNodeList.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 13bb2b1ad8..4fbb1d14fe 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -309,13 +309,16 @@ int LimitedNodeList::updateNodeWithDataFromPacket(const SharedNodePointer& match matchingNode->setLastHeardMicrostamp(usecTimestampNow()); - if (!matchingNode->getLinkedData() && linkedDataCreateCallback) { + NodeData* linkedData = matchingNode->getLinkedData(); + if (!linkedData && linkedDataCreateCallback) { linkedDataCreateCallback(matchingNode.data()); } - - QMutexLocker linkedDataLocker(&matchingNode->getLinkedData()->getMutex()); - - return matchingNode->getLinkedData()->parseData(packet); + + if (linkedData) { + QMutexLocker linkedDataLocker(&linkedData->getMutex()); + return linkedData->parseData(packet); + } + return 0; } int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packet) {