[Dbus-cxx-devel] DBus::Error Double Free
Status: Beta
Brought to you by:
rvinyard
From: Tyler C. <tc...@ta...> - 2010-01-18 16:46:02
|
I was calling a proxy method which didn't exist. The Exception which was thrown was causing a double free error on the destructor. The Dbus::Error was getting copied as it was passed down to the catch. I added a copy constructor which copies the DBusError name and message. It also checks to see if the error was already freed in the desctructor. diff -ru dbus-cxx-0.5.0.org/dbus-cxx/error.cpp dbus-cxx-0.5.0/dbus-cxx/error.cpp --- dbus-cxx-0.5.0.org/dbus-cxx/error.cpp 2009-09-29 13:26:15.000000000 -0700 +++ dbus-cxx-0.5.0/dbus-cxx/error.cpp 2010-01-18 08:20:46.000000000 -0800 @@ -27,6 +27,14 @@ dbus_error_init( &m_cobj ); } + Error::Error( const Error & rhs ) + { + dbus_error_init( &m_cobj ); + dbus_bool_t retVal = dbus_error_is_set(&m_cobj); + if(retVal == TRUE ) + dbus_set_error( &m_cobj, rhs.m_cobj.name, rhs.m_cobj.message ); + } + Error::Error( DBusError * cobj ) { dbus_error_init( &m_cobj ); @@ -61,7 +69,9 @@ Error::~Error( ) throw() { - dbus_error_free( &m_cobj ); + dbus_bool_t retVal = dbus_error_is_set(&m_cobj); + if(retVal == TRUE ) + dbus_error_free( &m_cobj ); } const char* Error::name() const diff -ru dbus-cxx-0.5.0.org/dbus-cxx/error.h dbus-cxx-0.5.0/dbus-cxx/error.h --- dbus-cxx-0.5.0.org/dbus-cxx/error.h 2009-05-05 15:17:50.000000000 -0700 +++ dbus-cxx-0.5.0/dbus-cxx/error.h 2010-01-15 14:47:32.000000000 -0800 @@ -55,6 +55,8 @@ Error(); + Error( const Error & rhs ); + Error( DBusError* cobj ); Error( const char* name, const char* message=NULL ); |