Fix a bug that can cause a crash if a peer requests an empty node.

This commit is contained in:
JoelKatz
2013-03-06 15:57:49 -08:00
parent 1f5cff396a
commit 646f7ca5de

View File

@@ -149,10 +149,16 @@ bool SHAMap::getNodeFat(const SHAMapNode& wanted, std::vector<SHAMapNode>& nodeI
SHAMapTreeNode::pointer node = getNode(wanted);
if (!node)
{
cLog(lsWARNING) << "peer requested node that not in the map: " << wanted;
cLog(lsWARNING) << "peer requested node that is not in the map: " << wanted;
throw std::runtime_error("Peer requested node not in map");
}
if (node->isEmpty())
{
cLog(lsWARNING) << "peer requests empty node";
return false;
}
nodeIDs.push_back(*node);
Serializer s;
node->addRaw(s, snfWIRE);