Author: amassari
Date: Fri May 23 10:50:16 2014
New Revision: 1597057

URL: http://svn.apache.org/r1597057
Log:
Prevent destructors closing a file from throwing an exception (XERCESC-2031)

Modified:
    xerces/c/trunk/src/xercesc/framework/LocalFileFormatTarget.cpp
    xerces/c/trunk/src/xercesc/internal/BinFileOutputStream.cpp
    xerces/c/trunk/src/xercesc/util/BinFileInputStream.cpp

Modified: xerces/c/trunk/src/xercesc/framework/LocalFileFormatTarget.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/framework/LocalFileFormatTarget.cpp?rev=1597057&r1=1597056&r2=1597057&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/framework/LocalFileFormatTarget.cpp (original)
+++ xerces/c/trunk/src/xercesc/framework/LocalFileFormatTarget.cpp Fri May 23 
10:50:16 2014
@@ -72,12 +72,12 @@ LocalFileFormatTarget::~LocalFileFormatT
         {
             // flush remaining buffer before destroy
             flush();
+            XMLPlatformUtils::closeFile(fSource, fMemoryManager);
         }
         catch (...)
         {
             // There is nothing we can do about it here.
         }
-        XMLPlatformUtils::closeFile(fSource, fMemoryManager);
     }
 
     fMemoryManager->deallocate(fDataBuf);//delete [] fDataBuf;

Modified: xerces/c/trunk/src/xercesc/internal/BinFileOutputStream.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/BinFileOutputStream.cpp?rev=1597057&r1=1597056&r2=1597057&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/BinFileOutputStream.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/BinFileOutputStream.cpp Fri May 23 
10:50:16 2014
@@ -34,12 +34,6 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  BinFileOutputStream: Constructors and Destructor
 // ---------------------------------------------------------------------------
-BinFileOutputStream::~BinFileOutputStream()
-{
-    if (getIsOpen())
-        XMLPlatformUtils::closeFile(fSource, fMemoryManager);
-}
-
 BinFileOutputStream::BinFileOutputStream(const XMLCh*   const fileName
                                          , MemoryManager* const manager)
 
@@ -55,6 +49,21 @@ BinFileOutputStream::BinFileOutputStream
 {
 }
 
+BinFileOutputStream::~BinFileOutputStream()
+{
+    if (getIsOpen())
+    {
+        try
+        {
+            XMLPlatformUtils::closeFile(fSource, fMemoryManager);
+        }
+        catch (...)
+        {
+            // There is nothing we can do about it here.
+        }
+    }
+}
+
 // ---------------------------------------------------------------------------
 //  BinFileOutputStream: Getter methods
 // ---------------------------------------------------------------------------

Modified: xerces/c/trunk/src/xercesc/util/BinFileInputStream.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/BinFileInputStream.cpp?rev=1597057&r1=1597056&r2=1597057&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/BinFileInputStream.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/BinFileInputStream.cpp Fri May 23 10:50:16 
2014
@@ -61,7 +61,16 @@ BinFileInputStream::BinFileInputStream(c
 BinFileInputStream::~BinFileInputStream()
 {
     if (getIsOpen())
-        XMLPlatformUtils::closeFile(fSource, fMemoryManager);
+    {
+        try
+        {
+            XMLPlatformUtils::closeFile(fSource, fMemoryManager);
+        }
+        catch (...)
+        {
+            // There is nothing we can do about it here.
+        }
+    }
 }
 
 



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

Reply via email to