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

Use of deleted pointer in NonPositiveInteger::serialize

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6 Final
    • current (nightly)
    • Serialization
    • None
    • All platforms, this issue was found in nightly CVS drop 20060125052126

    Description

      File: soap\xsd\NonPositiveInteger.cpp
      Method: AxisChar* NonPositiveInteger::serialize(const xsd__nonPositiveInteger* value)
      Row: 152 - 161

      This is a snippet of the code to illustrate the problem, starting on line 152.
      // ** maxInclusive is deleted.
      delete maxInclusive;

      MaxExclusive* maxExclusive = getMaxExclusive();
      if (maxExclusive->isSet())
      {
      if ( *value <= maxExclusive->getMaxExclusiveAsUnsignedLONGLONG() )
      {
      AxisString exceptionMessage =
      "Value to be serialized is greater than or equal to MaxExclusive specified for this type. MaxExclusive = ";
      //** Here maxInclusive is used again, after being deleted.
      if (maxInclusive->getMaxInclusiveAsUnsignedLONGLONG() != 0)

      { exceptionMessage += "-"; }

      Probably line 161 should read

      if (maxExclusive->getMaxExclusiveAsUnsignedLONGLONG() != 0)

      or maxInclusive should not be deleted until later.

      I would recommend use of std::auto_ptr to keep track of memory allocation here,
      which has the added benefit of making the code exception safe. Note that this file has
      numerous memory leaks in case an exception is thrown!

      /Emanuel

      Attachments

        Activity

          People

            Unassigned Unassigned
            emanuel Emanuel Norrbin
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: