From 149a42cc94728263b4a94b78909d1e4d329be891 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 9 Aug 2013 13:24:05 +0200 Subject: [PATCH] Fixing coverity issue 1046672 and a potential memory leak --- Library/OSRM.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/OSRM.cpp b/Library/OSRM.cpp index f8146995c..629e43978 100644 --- a/Library/OSRM.cpp +++ b/Library/OSRM.cpp @@ -88,7 +88,10 @@ OSRM::~OSRM() { void OSRM::RegisterPlugin(BasePlugin * plugin) { SimpleLogger().Write() << "loaded plugin: " << plugin->GetDescriptor(); - pluginMap[plugin->GetDescriptor()] = plugin; + if( pluginMap.find(plugin->GetDescriptor()) != pluginMap.end() ) { + delete pluginMap[plugin->GetDescriptor()]; + } + pluginMap.insert(std::make_pair(plugin->GetDescriptor(), plugin)); } void OSRM::RunQuery(RouteParameters & route_parameters, http::Reply & reply) {