double free - and that's never crashed us before .. in how many years?

This commit is contained in:
Timothee Besset 2013-06-07 04:39:38 +01:00
parent 5d0b2a2b94
commit 4c9f5c5229

View file

@ -97,6 +97,7 @@ CSynapseServer::CSynapseServer(){
CSynapseServer::~CSynapseServer(){ CSynapseServer::~CSynapseServer(){
if ( m_api_name ) { if ( m_api_name ) {
xmlFree( m_api_name ); xmlFree( m_api_name );
m_api_name = NULL;
} }
if ( m_content ) { if ( m_content ) {
g_free( m_content ); g_free( m_content );
@ -713,6 +714,7 @@ bool CSynapseServer::GetNextConfig( char **api_name, char **minor ){
if ( mpFocusedNode->type == XML_ELEMENT_NODE && !strcmp( (const char *)mpFocusedNode->name, "api" ) ) { if ( mpFocusedNode->type == XML_ELEMENT_NODE && !strcmp( (const char *)mpFocusedNode->name, "api" ) ) {
if ( m_api_name ) { if ( m_api_name ) {
xmlFree( m_api_name ); xmlFree( m_api_name );
m_api_name = NULL;
} }
m_api_name = xmlGetProp( mpFocusedNode, (const xmlChar *)"name" ); m_api_name = xmlGetProp( mpFocusedNode, (const xmlChar *)"name" );
*api_name = (char *)m_api_name; *api_name = (char *)m_api_name;
@ -736,6 +738,7 @@ bool CSynapseServer::GetConfigForAPI( const char *api, char **minor ) {
if ( pNode->type == XML_ELEMENT_NODE && !strcmp( (const char *)pNode->name, "api" ) ) { if ( pNode->type == XML_ELEMENT_NODE && !strcmp( (const char *)pNode->name, "api" ) ) {
if ( m_api_name ) { if ( m_api_name ) {
xmlFree( m_api_name ); xmlFree( m_api_name );
m_api_name = NULL;
} }
m_api_name = xmlGetProp( pNode, (const xmlChar *)"name" ); m_api_name = xmlGetProp( pNode, (const xmlChar *)"name" );
if ( !strcmp( (const char *)m_api_name, api ) ) { if ( !strcmp( (const char *)m_api_name, api ) ) {