From 65261babf4fbcba08deb7bc8871b8dbcbafcc26f Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 28 Apr 2019 12:51:24 +0300 Subject: 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 --- .../source/skeletonmaker/cppcompskeleton.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'unodevtools') 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(pofs)->is_open()) { - static_cast(pofs)->close(); + if (!standardout) + { + if (static_cast(pofs)->is_open()) + static_cast(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(pofs)->is_open()) { + if (static_cast(pofs)->is_open()) static_cast(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(pofs)->is_open()) { - static_cast(pofs)->close(); + if (!standardout) + { + if (static_cast(pofs)->is_open()) + static_cast(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(pofs)->is_open()) { + if (static_cast(pofs)->is_open()) static_cast(pofs)->close(); - delete pofs; - } + delete pofs; // remove existing type file if something goes wrong to ensure // consistency if (fileExists(compFileName)) -- cgit