From 57797329d13e5e670cfd3954965f3d181e3927f4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Feb 2015 12:14:03 -0800 Subject: [PATCH 1/4] do sample size arithmetic before scaling by sizeof --- interface/src/audio/AudioScope.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/audio/AudioScope.cpp b/interface/src/audio/AudioScope.cpp index 45820e2393..8cc27341d6 100644 --- a/interface/src/audio/AudioScope.cpp +++ b/interface/src/audio/AudioScope.cpp @@ -230,7 +230,7 @@ int AudioScope::addSilenceToScope(QByteArray* byteArray, int frameOffset, int si int samplesToBufferEnd = _samplesPerScope - frameOffset; if (silentSamples > samplesToBufferEnd) { memset(destination + frameOffset, 0, samplesToBufferEnd * sizeof(int16_t)); - memset(destination, 0, silentSamples - samplesToBufferEnd * sizeof(int16_t)); + memset(destination, 0, (silentSamples - samplesToBufferEnd) * sizeof(int16_t)); } else { memset(destination + frameOffset, 0, silentSamples * sizeof(int16_t)); } From b69ab6c80df6d6befb183a756f6af4e54faedcbd Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Feb 2015 12:56:12 -0800 Subject: [PATCH 2/4] 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) { From a7d6d6d5618e6cf824a7815194517aed9f01740c Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 10:04:21 -0800 Subject: [PATCH 3/4] return non-trivial value --- libraries/networking/src/LimitedNodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 4fbb1d14fe..4811c9c1ff 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -325,7 +325,7 @@ int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packe SharedNodePointer matchingNode = sendingNodeForPacket(packet); if (matchingNode) { - updateNodeWithDataFromPacket(matchingNode, packet); + return updateNodeWithDataFromPacket(matchingNode, packet); } // we weren't able to match the sender address to the address we have for this node, unlock and don't parse From 488492126e3609ddac80a7b8e029dfc61777df64 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 10:08:20 -0800 Subject: [PATCH 4/4] fix typo in comment --- libraries/networking/src/NodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index d35e11a1c3..f70c2d9b3c 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -347,7 +347,7 @@ void NodeList::handleICEConnectionToDomainServer() { qDebug() << "Sending ping packets to establish connectivity with domain-server with ID" << uuidStringWithoutCurlyBraces(_domainHandler.getICEDomainID()); - // send the ping packet to the local and public sockets for this nodfe + // send the ping packet to the local and public sockets for this node QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID()); writeUnverifiedDatagram(localPingPacket, _domainHandler.getICEPeer().getLocalSocket());