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

wrong use of delete keyword in DTest.cpp

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4
    • 3.2.0
    • Samples/Tests
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: