axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis Linine (JIRA)" <axis-c-...@ws.apache.org>
Subject [jira] Created: (AXISCPP-817) Possible memory leaks in the int Call::setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value) - src\engine\client\Call.cpp file
Date Fri, 26 Aug 2005 21:22:25 GMT
Possible memory leaks in the int Call::setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE
type, const char* value) - src\engine\client\Call.cpp file
-------------------------------------------------------------------------------------------------------------------------------------------------------

         Key: AXISCPP-817
         URL: http://issues.apache.org/jira/browse/AXISCPP-817
     Project: Axis-C++
        Type: Bug
  Components: Client - Engine  
    Versions: current (nightly)    
 Reporter: Denis Linine
    Priority: Minor


This code:

int Call::setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value)
{
	int	iSuccess = AXIS_SUCCESS;

    // Samisa - if SOAPAction is being set add extra "" to value
    if (type == SOAPACTION_HEADER)
    {
        char* tempvalue = new char[strlen(value) + 3];
        sprintf( tempvalue, "\"%s\"", value);
        m_pTransport->setTransportProperty(type, tempvalue);
        delete [] tempvalue;
    }
    else
	{
		try
		{
			iSuccess = m_pTransport->setTransportProperty( type, value);
		}
		catch( AxisException& e)
		{
			char *	pszError = new char[strlen( e.what()) + 1];
			strcpy( pszError, e.what());

			throw AxisGenException(e.getExceptionCode(), const_cast<char*>(pszError));
		}
	}

	if( iSuccess < 0)
	{
		string	sError = m_pTransport->getLastChannelError();
		char *	pszError = new char[sError.length() + 1];
		strcpy( pszError, sError.c_str());
		throw AxisGenException( -iSuccess, const_cast<char*>(pszError));
	}

    return iSuccess;
}

may introduce memory leaks when throwing exceptions, could be rewritten like this:

int Call::setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value)
{
	int	iSuccess = AXIS_SUCCESS;

    // Samisa - if SOAPAction is being set add extra "" to value
    if (type == SOAPACTION_HEADER)
    {
        char* tempvalue = new char[strlen(value) + 3];
        sprintf( tempvalue, "\"%s\"", value);
        m_pTransport->setTransportProperty(type, tempvalue);
        delete [] tempvalue;
    }
    else
	{
		try
		{
			iSuccess = m_pTransport->setTransportProperty( type, value);
		}
		catch( AxisException& e)
		{
			throw AxisGenException(e.getExceptionCode(), e.what());
		}
	}

	if( iSuccess < 0)
	{
		throw AxisGenException( -iSuccess, m_pTransport->getLastChannelError());
	}

    return iSuccess;
}





-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message