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

Memory leak occurs if an exception is thrown in TranscodeToStr or TranscodeFromStr constructors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.1
    • 3.1.2, 3.2.0
    • Utilities
    • Any

    Description

      The constructor for TranscodeToStr calls TranscodeToStr::transcode(). That method allocates memory for fString, but it is possible for an exception to occur shortly thereafter; it might be thrown directly by transcode(), or by the transcoder method call trans->transcodeTo(). Since we are still in the constructor, TranscodeToStr's destructor will not be called during the stack unwind to clean up (see http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.10 ). Therefore, we have to explicitly make sure fString will be deallocated. Since the current code doesn't do that, it leaks memory. TranscodeFromStr is in the same situation.

      I have a simple patch that I expect to post later tonight.

      Attachments

        1. TransService.cpp.patch
          2 kB
          Lee Doron

        Activity

          People

            amassari Alberto Massari
            ldoron Lee Doron
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: