Skip to content

Commit

Permalink
Changes exception message in Cluster::getNodeById to use boost::format.
Browse files Browse the repository at this point in the history
The previous code would cause a segmentation fault if nodeId was greater than the string length, and the message now actually includes the ID.
  • Loading branch information
tgockel authored and arunthirupathi committed Aug 7, 2014
1 parent a51f328 commit 9f40015
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clients/cpp/src/Cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include "Cluster.h"
#include <voldemort/VoldemortException.h>
#include <iostream>
#include <string.h>
#include <cstring>
#include <boost/format.hpp>

namespace Voldemort {

Expand Down Expand Up @@ -183,7 +184,7 @@ boost::shared_ptr<Node>& Cluster::getNodeById(int nodeId) {
if (nodesById.count(nodeId))
return nodesById[nodeId];
else
throw VoldemortException("Invalid node ID: " + nodeId);
throw VoldemortException(str(boost::format("Invalid node ID: %1%") % nodeId));
}

std::ostream& operator<<(std::ostream& output, const Cluster& cluster) {
Expand Down

0 comments on commit 9f40015

Please sign in to comment.