Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-2050

wrong use of delete keyword in DTest.cpp

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4
    • Fix Version/s: 3.2.0
    • Component/s: Samples/Tests
    • Labels:
      None
    • Flags:
      Patch

      Description

      In the file DTest.cpp there is a wrong use of the delete keyword. The variable hugeString is allocated with:
      char* hugeString=new char[HUGE_STRING+1];
      It gets deallocated with:
      delete hugeString;

      When allocating a variable with "new type[size]" one has to deallocate with "delete [] variable". These kinds of errors can be seen when compiling with address sanitizer. I'll attach a patch.

        Attachments

        1. xerces-c-fix-alloc-dealloc.diff
          0.3 kB
          Hanno Böck

          Activity

            People

            • Assignee:
              amassari Alberto Massari
              Reporter:
              hanno Hanno Böck
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: