Kaydet (Commit) 65261bab authored tarafından Mike Kaganski's avatar Mike Kaganski

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: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst da92911d
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment