From: Richard Whitehouse Date: Sat, 16 Apr 2011 17:06:20 +0000 (+0100) Subject: Fencepost error X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=7cc97753bc117ee21e3e9c659fc0e2b0e5c26abe;p=ns-moose.git Fencepost error --- diff --git a/src/topology/model/topology.cc b/src/topology/model/topology.cc index 3b5c509..68bfab9 100644 --- a/src/topology/model/topology.cc +++ b/src/topology/model/topology.cc @@ -68,19 +68,19 @@ Topology::Topology(std::istream& file){ file >> source; file >> destination; if(file.good()){ - if(source > bridges){ // Source is a host + if(source >= bridges){ // Source is a host source -= bridges; - if(source > hosts){ + if(source >= hosts){ throw new std::runtime_error("Invalid Link in Topology"); } - if(destination > bridges){ // Dest is a host + if(destination >= bridges){ // Dest is a host throw new std::runtime_error("Host-Host Link in Topology"); } hostLinks[source] = destination; } else { // Source is a bridge - if(destination > bridges){ // Source is a host + if(destination >= bridges){ // Source is a host destination -= bridges; - if(destination > hosts){ + if(destination >= hosts){ throw new std::runtime_error("Invalid Host Link"); } hostLinks[destination] = source;