Skip to content

Commit ad9ccf1

Browse files
committed
converted CppCheckExecutor::mErrorOutput to safe_ptr
1 parent f131478 commit ad9ccf1

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,10 @@ cli/cmdlineparser.o: cli/cmdlineparser.cpp cli/cmdlineparser.h cli/cppcheckexecu
641641
cli/cppcheckexecutor.o: cli/cppcheckexecutor.cpp cli/cmdlineparser.h cli/cppcheckexecutor.h cli/cppcheckexecutorseh.h cli/cppcheckexecutorsig.h cli/executor.h cli/filelister.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h lib/analyzerinfo.h lib/check.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/safeptr.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
642642
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cppcheckexecutor.cpp
643643

644-
cli/cppcheckexecutorseh.o: cli/cppcheckexecutorseh.cpp cli/cppcheckexecutor.h cli/cppcheckexecutorseh.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/utils.h
644+
cli/cppcheckexecutorseh.o: cli/cppcheckexecutorseh.cpp cli/cppcheckexecutor.h cli/cppcheckexecutorseh.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/safeptr.h lib/utils.h
645645
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cppcheckexecutorseh.cpp
646646

647-
cli/cppcheckexecutorsig.o: cli/cppcheckexecutorsig.cpp cli/cppcheckexecutor.h cli/cppcheckexecutorsig.h cli/stacktrace.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h
647+
cli/cppcheckexecutorsig.o: cli/cppcheckexecutorsig.cpp cli/cppcheckexecutor.h cli/cppcheckexecutorsig.h cli/stacktrace.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/safeptr.h
648648
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cppcheckexecutorsig.cpp
649649

650650
cli/executor.o: cli/executor.cpp cli/executor.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
@@ -653,7 +653,7 @@ cli/executor.o: cli/executor.cpp cli/executor.h lib/color.h lib/config.h lib/err
653653
cli/filelister.o: cli/filelister.cpp cli/filelister.h lib/config.h lib/path.h lib/pathmatch.h lib/utils.h
654654
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/filelister.cpp
655655

656-
cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h
656+
cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/safeptr.h
657657
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/main.cpp
658658

659659
cli/processexecutor.o: cli/processexecutor.cpp cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/safeptr.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h

cli/cppcheckexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class XMLErrorMessagesLogger : public ErrorLogger
8989

9090
CppCheckExecutor::~CppCheckExecutor()
9191
{
92-
delete mErrorOutput;
92+
delete mErrorOutput.get();
9393
}
9494

9595
bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* const argv[])
@@ -280,7 +280,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
280280
mLatestProgressOutputTime = std::time(nullptr);
281281

282282
if (!settings.outputFile.empty()) {
283-
mErrorOutput = new std::ofstream(settings.outputFile);
283+
mErrorOutput = safe_ptr<std::ofstream>(new std::ofstream(settings.outputFile));
284284
}
285285

286286
if (settings.xml) {

cli/cppcheckexecutor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "color.h"
2323
#include "errorlogger.h"
24+
#include "safeptr.h"
2425

2526
#include <cstdio>
2627
#include <ctime>
@@ -181,7 +182,7 @@ class CppCheckExecutor : public ErrorLogger {
181182
/**
182183
* Error output
183184
*/
184-
std::ofstream* mErrorOutput{};
185+
safe_ptr<std::ofstream> mErrorOutput;
185186
};
186187

187188
#endif // CPPCHECKEXECUTOR_H

0 commit comments

Comments
 (0)