Uploaded image for project: 'Axis-C++'
  1. Axis-C++
  2. AXISCPP-808

possible memory leak in the AxisChar* Double::serialize(const xsd__double* value) function

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • current (nightly)
    • 1.6 Alpha
    • XSD Types
    • None

    Description

      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.

      Attachments

        Activity

          People

            samisa Don Samisa Abeysinghe
            den Denis Linine
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: