This is an automated email from the ASF dual-hosted git repository.

scantor pushed a commit to branch xerces-3.2
in repository https://gitbox.apache.org/repos/asf/xerces-c.git


The following commit(s) were added to refs/heads/xerces-3.2 by this push:
     new 35a0cb4a2 IGXMLScanner::scanDocTypeDecl(): fix memory leak on exception
35a0cb4a2 is described below

commit 35a0cb4a2eaeab18988e2fada2d6547ba2fdbbf7
Author: Even Rouault <even.roua...@spatialys.com>
AuthorDate: Fri Oct 29 01:20:14 2021 +0200

    IGXMLScanner::scanDocTypeDecl(): fix memory leak on exception
    
    The method can leak pubId and sysId when subsequent call to
    fReaderMgr.skipPastSpaces() throws an exception (e.g. a
    TranscodingException)
---
 src/xercesc/internal/IGXMLScanner.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/xercesc/internal/IGXMLScanner.cpp 
b/src/xercesc/internal/IGXMLScanner.cpp
index 00624009d..912ec0c62 100644
--- a/src/xercesc/internal/IGXMLScanner.cpp
+++ b/src/xercesc/internal/IGXMLScanner.cpp
@@ -1374,7 +1374,14 @@ void IGXMLScanner::scanDocTypeDecl()
         // Get copies of the ids we got
         pubId = XMLString::replicate(bbPubId.getRawBuffer(), fMemoryManager);
         sysId = XMLString::replicate(bbSysId.getRawBuffer(), fMemoryManager);
+    }
+
+    // Insure that the ids get cleaned up, if they got allocated
+    ArrayJanitor<XMLCh> janSysId(sysId, fMemoryManager);
+    ArrayJanitor<XMLCh> janPubId(pubId, fMemoryManager);
 
+    if (hasExtSubset)
+    {
         // Skip spaces and check again for the opening of an internal subset
         fReaderMgr.skipPastSpaces();
 
@@ -1384,10 +1391,6 @@ void IGXMLScanner::scanDocTypeDecl()
         }
     }
 
-    // Insure that the ids get cleaned up, if they got allocated
-    ArrayJanitor<XMLCh> janSysId(sysId, fMemoryManager);
-    ArrayJanitor<XMLCh> janPubId(pubId, fMemoryManager);
-
     //  If we have a doc type handler and advanced callbacks are enabled,
     //  call the doctype event.
     if (fDocTypeHandler)


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org

Reply via email to