Fix issue when service fails to load
authorDavin McCall <davmac@davmac.org>
Thu, 26 Dec 2019 04:15:27 +0000 (04:15 +0000)
committerDavin McCall <davmac@davmac.org>
Thu, 26 Dec 2019 04:15:27 +0000 (04:15 +0000)
Introduced during earlier refactoring.

src/load-service.cc

index 3a777d31a134987a5bb39ae79ea21256f0510924..fe39771546251b4d8e482dff34c5ba47ea202661 100644 (file)
@@ -513,7 +513,7 @@ service_record * dirload_service_set::load_reload_service(const char *name, serv
     {
         // Must remove the dummy service record.
         if (dummy != nullptr) {
-            records.erase(std::find(records.begin(), records.end(), rval));
+            records.erase(std::find(records.begin(), records.end(), dummy));
             delete dummy;
         }
         if (create_new_record) delete rval;
@@ -522,7 +522,7 @@ service_record * dirload_service_set::load_reload_service(const char *name, serv
     catch (std::system_error &sys_err)
     {
         if (dummy != nullptr) {
-            records.erase(std::find(records.begin(), records.end(), rval));
+            records.erase(std::find(records.begin(), records.end(), dummy));
             delete dummy;
         }
         if (create_new_record) delete rval;
@@ -531,7 +531,7 @@ service_record * dirload_service_set::load_reload_service(const char *name, serv
     catch (...) // (should only be std::bad_alloc / service_description_exc)
     {
         if (dummy != nullptr) {
-            records.erase(std::find(records.begin(), records.end(), rval));
+            records.erase(std::find(records.begin(), records.end(), dummy));
             delete dummy;
         }
         if (create_new_record) delete rval;