[ http://issues.apache.org/jira/browse/AXISCPP-808?page=comments#action_12319844 ]
Denis Linine commented on AXISCPP-808: -------------------------------------- I think that one could even change the code so that getMaxInclusive() and similar functions would return objects by value. Returned types are very simple and do not even require overloaded copy constructors and assignment operators. Returning them by value should work faster than in case where heap allocation/deallocation is invoked and would make impossible mistakes like the one that caused this message . > possible memory leak in the AxisChar* Double::serialize(const xsd__double* > value) function > ------------------------------------------------------------------------------------------ > > Key: AXISCPP-808 > URL: http://issues.apache.org/jira/browse/AXISCPP-808 > Project: Axis-C++ > Type: Bug > Reporter: Denis Linine > Priority: Trivial > > Hi > Here is the code from the Double.cpp file. > AxisChar* Double::serialize(const xsd__double* value) throw > (AxisSoapException) > { > MinInclusive* minInclusive = getMinInclusive(); > if (minInclusive->isSet()) > { > if ( *value < minInclusive->getMinInclusiveAsDouble() ) > { > AxisString exceptionMessage = > "Value to be serialized is less than MinInclusive specified for > this type. MinInclusive = "; > AxisChar* length = new AxisChar[25]; > sprintf(length, "%f", minInclusive->getMinInclusiveAsDouble()); > exceptionMessage += length; > exceptionMessage += ", Value = "; > sprintf(length, "%f", *value); > exceptionMessage += length; > exceptionMessage += "."; > delete [] length; > > throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR, > const_cast<AxisChar*>(exceptionMessage.c_str())); > } > } > delete minInclusive; > MinExclusive* minExclusive = getMinExclusive(); > if (minExclusive->isSet()) > { > if ( *value <= minExclusive->getMinExclusiveAsDouble() ) > { > AxisString exceptionMessage = > "Value to be serialized is less than or equal to MinExclusive > specified for this type. MinExclusive = "; > AxisChar* length = new AxisChar[25]; > sprintf(length, "%f", minExclusive->getMinExclusiveAsDouble()); > exceptionMessage += length; > exceptionMessage += ", Value = "; > sprintf(length, "%f", *value); > exceptionMessage += length; > exceptionMessage += "."; > delete [] length; > > throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR, > const_cast<AxisChar*>(exceptionMessage.c_str())); > } > } > delete minExclusive; > > MaxInclusive* maxInclusive = getMaxInclusive(); > if (maxInclusive->isSet()) > { > if ( *value > maxInclusive->getMaxInclusiveAsDouble() ) > { > AxisString exceptionMessage = > "Value to be serialized is greater than MaxInclusive specified > for this type. MaxInclusive = "; > AxisChar* length = new AxisChar[25]; > sprintf(length, "%f", maxInclusive->getMaxInclusiveAsDouble()); > exceptionMessage += length; > exceptionMessage += ", Value = "; > sprintf(length, "%f", *value); > exceptionMessage += length; > exceptionMessage += "."; > delete [] length; > > throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR, > const_cast<AxisChar*>(exceptionMessage.c_str())); > } > } > delete maxInclusive; > MaxExclusive* maxExclusive = getMaxExclusive(); > if (maxExclusive->isSet()) > { > if ( *value >= maxExclusive->getMaxExclusiveAsDouble() ) > { > AxisString exceptionMessage = > "Value to be serialized is greater than or equal to MaxExclusive > specified for this type. MaxExclusive = "; > AxisChar* length = new AxisChar[25]; > sprintf(length, "%f", maxExclusive->getMaxExclusiveAsDouble()); > exceptionMessage += length; > exceptionMessage += ", Value = "; > sprintf(length, "%f", *value); > exceptionMessage += length; > exceptionMessage += "."; > delete [] length; > > throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR, > const_cast<AxisChar*>(exceptionMessage.c_str())); > } > } > delete maxExclusive; > > AxisChar* serializedValue = new char[80]; > AxisSprintf (serializedValue, 80, "%f", *value); > > IAnySimpleType::serialize(serializedValue); > delete [] serializedValue; > return m_Buf; > } > it seems that the memory used by minInclusive, minExclusive , etc will not > be freed if an exception is thrown. -- 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
