[Libreoffice-commits] core.git: unodevtools/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Sun Apr 28 11:16:23 UTC 2019


 unodevtools/source/skeletonmaker/cppcompskeleton.cxx |   22 ++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

New commits:
commit 65261babf4fbcba08deb7bc8871b8dbcbafcc26f
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Apr 28 12:51:24 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Apr 28 13:15:39 2019 +0200

    tdf#120703 PVS: fix cleanup checks
    
    pofs is guaranteed to be non-nullptr after getOutputStream, so no need
    to check that. is_open() only matters to decide if close() is needed.
    
    V595 The 'pofs' pointer was utilized before it was verified against nullptr.
         Check lines: 1033, 1057.
         Check lines: 1194, 1220.
    
    Change-Id: I2dd22d29c465889269f2496f0964bee030cb5964
    Reviewed-on: https://gerrit.libreoffice.org/71456
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
index c1fec780e9ff..2d0eb0d3e45f 100644
--- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
@@ -1034,18 +1034,19 @@ void generateSkeleton(ProgramOptions const & options,
             *pofs << (nm > 0 ? "// closing namespace\n\n" : "\n");
         }
 
-        if ( !standardout && pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
-            static_cast<std::ofstream*>(pofs)->close();
+        if (!standardout)
+        {
+            if (static_cast<std::ofstream*>(pofs)->is_open())
+                static_cast<std::ofstream*>(pofs)->close();
             delete pofs;
             OSL_VERIFY(makeValidTypeFile(compFileName, tmpFileName, false));
         }
     } catch (CannotDumpException & e) {
         std::cerr << "ERROR: " << e.getMessage() << "\n";
         if ( !standardout ) {
-            if (pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
+            if (static_cast<std::ofstream*>(pofs)->is_open())
                 static_cast<std::ofstream*>(pofs)->close();
-                delete pofs;
-            }
+            delete pofs;
             // remove existing type file if something goes wrong to ensure
             // consistency
             if (fileExists(compFileName))
@@ -1193,18 +1194,19 @@ void generateCalcAddin(ProgramOptions const & options,
 
         generateCompFunctions(*pofs, nmspace);
 
-        if ( !standardout && pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
-            static_cast<std::ofstream*>(pofs)->close();
+        if (!standardout)
+        {
+            if (static_cast<std::ofstream*>(pofs)->is_open())
+                static_cast<std::ofstream*>(pofs)->close();
             delete pofs;
             OSL_VERIFY(makeValidTypeFile(compFileName, tmpFileName, false));
         }
     } catch (CannotDumpException & e) {
         std::cerr << "ERROR: " << e.getMessage() << "\n";
         if ( !standardout ) {
-            if (pofs && static_cast<std::ofstream*>(pofs)->is_open()) {
+            if (static_cast<std::ofstream*>(pofs)->is_open())
                 static_cast<std::ofstream*>(pofs)->close();
-                delete pofs;
-            }
+            delete pofs;
             // remove existing type file if something goes wrong to ensure
             // consistency
             if (fileExists(compFileName))


More information about the Libreoffice-commits mailing list