You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Denis Linine (JIRA)" <ax...@ws.apache.org> on 2005/08/26 23:22:25 UTC

[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

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


[jira] Assigned: (AXISCPP-817) Possible memory leaks in the int Call::setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value) - src\engine\client\Call.cpp file

Posted by "Samisa Abeysinghe (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-817?page=all ]

Samisa Abeysinghe reassigned AXISCPP-817:
-----------------------------------------

    Assign To: Samisa Abeysinghe

> 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
>     Assignee: Samisa Abeysinghe
>     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


[jira] Closed: (AXISCPP-817) Possible memory leaks in the int Call::setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value) - src\engine\client\Call.cpp file

Posted by "Samisa Abeysinghe (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-817?page=all ]
     
Samisa Abeysinghe closed AXISCPP-817:
-------------------------------------

    Fix Version: 1.6 Alpha
     Resolution: Fixed

Fixed the problem by applying the suggested solution.
Thanks Denis for the contribution

> 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
>     Assignee: Samisa Abeysinghe
>     Priority: Minor
>      Fix For: 1.6 Alpha

>
> 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