[GitHub] [xerces-c] rleigh-codelibre commented on a change in pull request #44: [XERCESC-2233] DFAContentModel: :buildDFA(): fix memory leaks when OutOfMemoryException o ccurs

GitBox <[email protected]>
Newsgroups gmane.text.xml.xerces-c.devel
Message-ID <[email protected]>
rleigh-codelibre commented on a change in pull request #44:
URL: https://github.com/apache/xerces-c/pull/44#discussion_r762456999



##########
File path: src/xercesc/validators/common/DFAContentModel.cpp
##########
@@ -1191,12 +1203,21 @@ void DFAContentModel::buildDFA(ContentSpecNode* const curNode)
                     //  table.
                     //
                     statesToDo[curState] = newSet;
-                    fTransTable[curState] = makeDefStateList();
-                    stateTable->put
-                    (
-                        newSet
-                        , new (fMemoryManager) XMLInteger(curState)
-                    );
+                    try
+                    {
+                        fTransTable[curState] = makeDefStateList();
+                        stateTable->put
+                        (
+                            newSet
+                            , new (fMemoryManager) XMLInteger(curState)
+                        );
+                    }
+                    catch( const OutOfMemoryException& e )
+                    {
+                        oomException = e;

Review comment:
       How safe is the saving and re-throwing of the exception?  Is there any potential for `OutOfMemoryException& e` to be a reference to a base class?  Could `e` end up being truncated as a result?  A direct `throw` to rethrow the existing exception might be safer overall, and avoid the need for a goto.
   
   Could we achieve the same effect with a higher-level try/catch block within the function, and avoid the saving of the exception and the goto?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.