summaryrefslogtreecommitdiff
path: root/src/driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/driver.cpp')
-rw-r--r--src/driver.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/driver.cpp b/src/driver.cpp
index 63e76cffa..b042ea620 100644
--- a/src/driver.cpp
+++ b/src/driver.cpp
@@ -156,7 +156,9 @@ void DriverFactoryBase::RegisterDriver(const char *name, Driver::Type type, int
strecpy(buf, GetDriverTypeName(type), lastof(buf));
strecpy(buf + 5, name, lastof(buf));
- std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(buf, this));
+ const char *longname = strdup(buf);
+
+ std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
assert(P.second);
}
@@ -194,7 +196,14 @@ DriverFactoryBase::~DriverFactoryBase() {
strecpy(buf, GetDriverTypeName(type), lastof(buf));
strecpy(buf + 5, this->name, lastof(buf));
- GetDrivers().erase(buf);
+ Drivers::iterator it = GetDrivers().find(buf);
+ assert(it != GetDrivers().end());
+
+ const char *longname = (*it).first;
+
+ GetDrivers().erase(it);
+ free((void *)longname);
+
if (GetDrivers().empty()) delete &GetDrivers();
- free(this->name);
+ free((void *)this->name);
}