From fdf4a61ed5db7d63eb51e72a143abd7fb97a32c8 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Thu, 19 Nov 2015 23:17:58 +0100 Subject: [PATCH] fgcommand remove-subsystem: fix double delete/segfault. --- src/Main/subsystemFactory.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Main/subsystemFactory.cxx b/src/Main/subsystemFactory.cxx index bd0d0057f..aeb61aa56 100644 --- a/src/Main/subsystemFactory.cxx +++ b/src/Main/subsystemFactory.cxx @@ -202,23 +202,20 @@ do_add_subsystem (const SGPropertyNode * arg) static bool do_remove_subsystem(const SGPropertyNode * arg) { std::string name = arg->getStringValue("subsystem"); - + SGSubsystem* instance = globals->get_subsystem_mgr()->get_subsystem(name); if (!instance) { SG_LOG(SG_GENERAL, SG_ALERT, "do_remove_subsystem: unknown subsytem:" << name); return false; } - + // is it safe to always call these? let's assume so! instance->shutdown(); instance->unbind(); - // unplug from the manager + // unplug from the manager (this also deletes the instance!) globals->get_subsystem_mgr()->remove(name.c_str()); - - // and finally kill off the instance. - delete instance; - + return true; } -- 2.39.5