options: remove memory leak

This commit is contained in:
Danny Robson 2015-04-29 17:10:33 +10:00
parent 33401becbd
commit 97de4a2bd6

View File

@ -446,17 +446,13 @@ processor::parse_long (int pos, int argc, const char ** argv) {
// Skip past the dashes to the argument name // Skip past the dashes to the argument name
arg += 2; arg += 2;
// If there's an equals it's has a value to extract // If there's an equals it has a value to extract
const char *data = strchr (arg, '='); const char *data = strchr (arg, '=');
if (data) { option *o = data ? m_longopt[std::string (arg, data++)]
arg = strndup (arg, sign_cast<size_t> (data - arg)); : m_longopt[arg];
//arg = strndup (arg, data - arg); // Copy just the arg name
++data; // Skip the '='
}
option *o = m_longopt[arg];
if (!o) if (!o)
throw runtime_error ("Cannot match option"); throw std::runtime_error ("Cannot match option");
if (data) if (data)
o->execute (data); o->execute (data);