fix coverity issue 1121924, Resource leak

This commit is contained in:
Dennis Luxen 2013-10-31 14:05:06 +01:00
parent 9730526d33
commit 190def17e5

View File

@ -231,54 +231,76 @@ inline bool GenerateServerProgramOptions(
} }
if( !use_shared_memory ) { if( !use_shared_memory ) {
if( !option_variables.count("hsgrdata") ) { path_iterator = paths.find("hsgrdata");
if( !option_variables.count("base") ) { if(
path_iterator == paths.end() ||
boost::filesystem::is_regular_file(path_iterator->second) ||
!option_variables.count("base")
) {
throw OSRMException("hsgrdata (or base) must be specified"); throw OSRMException("hsgrdata (or base) must be specified");
} }
paths["hsgrdata"] = std::string( paths["base"].string()) + ".hsgr"; paths["hsgrdata"] = std::string( paths["base"].string()) + ".hsgr";
}
if(!option_variables.count("nodesdata")) { path_iterator = paths.find("nodesdata");
if(!option_variables.count("base")) { if(
path_iterator == paths.end() ||
boost::filesystem::is_regular_file(path_iterator->second) ||
!option_variables.count("base")
) {
throw OSRMException("nodesdata (or base) must be specified"); throw OSRMException("nodesdata (or base) must be specified");
} }
paths["nodesdata"] = std::string( paths["base"].c_str()) + ".nodes"; paths["nodesdata"] = std::string( paths["base"].string()) + ".nodes";
}
if(!option_variables.count("edgesdata")) { path_iterator = paths.find("edgesdata");
if(!option_variables.count("base")) { if(
path_iterator == paths.end() ||
boost::filesystem::is_regular_file(path_iterator->second) ||
!option_variables.count("base")
) {
throw OSRMException("edgesdata (or base) must be specified"); throw OSRMException("edgesdata (or base) must be specified");
} }
paths["edgesdata"] = std::string( paths["base"].c_str()) + ".edges"; paths["edgesdata"] = std::string( paths["base"].string()) + ".edges";
}
if(!option_variables.count("ramindex")) { path_iterator = paths.find("ramindex");
if(!option_variables.count("base")) { if(
path_iterator == paths.end() ||
boost::filesystem::is_regular_file(path_iterator->second) ||
!option_variables.count("base")
) {
throw OSRMException("ramindex (or base) must be specified"); throw OSRMException("ramindex (or base) must be specified");
} }
paths["ramindex"] = std::string( paths["base"].c_str()) + ".ramIndex"; paths["ramindex"] = std::string( paths["base"].string()) + ".ramIndex";
}
if(!option_variables.count("fileindex")) { path_iterator = paths.find("fileindex");
if(!option_variables.count("base")) { if(
path_iterator == paths.end() ||
boost::filesystem::is_regular_file(path_iterator->second) ||
!option_variables.count("base")
) {
throw OSRMException("fileindex (or base) must be specified"); throw OSRMException("fileindex (or base) must be specified");
} }
paths["fileindex"] = std::string( paths["base"].c_str()) + ".fileIndex"; paths["fileindex"] = std::string( paths["base"].string()) + ".fileIndex";
}
if(!option_variables.count("namesdata")) { path_iterator = paths.find("namesdata");
if(!option_variables.count("base")) { if(
path_iterator == paths.end() ||
boost::filesystem::is_regular_file(path_iterator->second) ||
!option_variables.count("base")
) {
throw OSRMException("namesdata (or base) must be specified"); throw OSRMException("namesdata (or base) must be specified");
} }
paths["namesdata"] = std::string( paths["base"].c_str()) + ".names"; paths["namesdata"] = std::string( paths["base"].string()) + ".names";
}
if(!option_variables.count("timestamp")) { path_iterator = paths.find("timestamp");
if(!option_variables.count("base")) { if(
path_iterator == paths.end() ||
boost::filesystem::is_regular_file(path_iterator->second) ||
!option_variables.count("base")
) {
throw OSRMException("timestamp (or base) must be specified"); throw OSRMException("timestamp (or base) must be specified");
} }
paths["timestamp"] = std::string( paths["base"].c_str()) + ".timestamp"; paths["timestamp"] = (paths["base"].string() + ".timestamp");
}
} }
if(1 > requested_num_threads) { if(1 > requested_num_threads) {
throw OSRMException("Number of threads must be a positive number"); throw OSRMException("Number of threads must be a positive number");