@@ -288,6 +288,8 @@ static void createDumpFile(const Settings& settings,
288288 fout.exceptions (std::ios_base::failbit | std::ios_base::badbit);
289289 fout.open (getCtuInfoFileName (dumpFile));
290290 assert (fout.is_open ()); // If we ever disable exceptions, catch issues ASAP
291+ fout.close ();
292+ assert (fout.good ()); // If we ever disable exceptions, catch issues ASAP
291293 }
292294
293295 std::string language;
@@ -421,6 +423,7 @@ CppCheck::~CppCheck()
421423 try
422424 {
423425 mPlistFile .close ();
426+ assert (mPlistFile .good ()); // If we ever disable exceptions, catch issues ASAP
424427 }
425428 catch (const std::ios_base::failure&)
426429 {
@@ -528,6 +531,8 @@ unsigned int CppCheck::check(const std::string &path)
528531 fout.open (clangcmd);
529532 assert (fout.is_open ()); // If we ever disable exceptions, catch issues ASAP
530533 fout << exe << " " << args2 << " " << redirect2 << std::endl;
534+ fout.close ();
535+ assert (fout.good ()); // If we ever disable exceptions, catch issues ASAP
531536 } else if (mSettings .verbose && !mSettings .quiet ) {
532537 mErrorLogger .reportOut (exe + " " + args2);
533538 }
@@ -562,6 +567,8 @@ unsigned int CppCheck::check(const std::string &path)
562567 fout.open (clangAst);
563568 assert (fout.is_open ()); // If we ever disable exceptions, catch issues ASAP
564569 fout << output2 << std::endl;
570+ fout.close ();
571+ assert (fout.good ()); // If we ever disable exceptions, catch issues ASAP
565572 }
566573
567574 try {
@@ -595,6 +602,7 @@ unsigned int CppCheck::check(const std::string &path)
595602 fdump << " </dump>" << std::endl;
596603 fdump << " </dumps>" << std::endl;
597604 fdump.close ();
605+ assert (fdump.good ()); // If we ever disable exceptions, catch issues ASAP
598606 }
599607
600608 // run addons
@@ -690,7 +698,9 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
690698
691699 if (mPlistFile .is_open ()) {
692700 mPlistFile << ErrorLogger::plistFooter ();
701+
693702 mPlistFile .close ();
703+ assert (mPlistFile .good ()); // If we ever disable exceptions, catch issues ASAP
694704 }
695705
696706 CheckUnusedFunctions checkUnusedFunctions (nullptr , nullptr , nullptr );
@@ -1031,6 +1041,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
10311041 if (fdump.is_open ()) {
10321042 fdump << " </dumps>" << std::endl;
10331043 fdump.close ();
1044+ assert (fdump.good ()); // If we ever disable exceptions, catch issues ASAP
10341045 }
10351046
10361047 executeAddons (dumpFile);
@@ -1459,6 +1470,9 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
14591470
14601471 for (const std::string& f: files)
14611472 fout << f << std::endl;
1473+
1474+ fout.close ();
1475+ assert (fout.good ()); // If we ever disable exceptions, catch issues ASAP
14621476 }
14631477
14641478 for (const std::string &addon : mSettings .addons ) {
@@ -1722,6 +1736,9 @@ void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings)
17221736 assert (fcmd.is_open ()); // If we ever disable exceptions, catch issues ASAP
17231737
17241738 fcmd << istr.str ();
1739+
1740+ fcmd.close ();
1741+ assert (fcmd.good ()); // If we ever disable exceptions, catch issues ASAP
17251742 }
17261743
17271744 while (std::getline (istr, line)) {
0 commit comments