Bug fix: return the boost::program_options::option_description by value
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 13 Sep 2011 04:07:55 +0000 (01:07 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 13 Sep 2011 04:07:55 +0000 (01:07 -0300)
- If this object is returned by reference or smart pointer, the
  boost::program_options::options_description::add() method will delete it
  causing double free on that object. So we prevent any problem by not exposing
  the underlying object

src/config/option/configurationoption.cpp
src/config/option/configurationoption.h

index da9bfbf..c281313 100644 (file)
@@ -70,9 +70,9 @@ ConfigurationOption::~ConfigurationOption()
 /**
  * @return The underlining @c boost::program_options::option_description object.
  */
-shared_ptr<option_description> ConfigurationOption::get_option_description()
+option_description ConfigurationOption::get_option_description()
 {
-    return shared_ptr<option_description>( &option );
+    return option;
 }
 
 /**
index e7552e5..7ee5079 100644 (file)
@@ -50,7 +50,7 @@ public:
     );
     virtual ~ConfigurationOption();
 
-    boost::shared_ptr< boost::program_options::option_description > get_option_description();
+    boost::program_options::option_description get_option_description();
     std::string get_command_string() const;
     std::string get_command_description() const;