diff options
author | Gereon Kremer <gereon.kremer@cs.rwth-aachen.de> | 2020-07-16 06:34:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-15 21:34:14 -0700 |
commit | 81821f40c36a6ccbee4bf6ef500cd5dccacb634c (patch) | |
tree | e3cfdc8797ed86143a351bf20883a803f76143b5 /src/main/command_executor.cpp | |
parent | 699af1774b7ddae0b1a8337cb4cd02532a6ad8b0 (diff) |
Fixes memory leak when an exception goes through runCvc4(). (Fixes #4590) (#4750)
As noted in #4590, CVC4 may leak memory if an exception is thrown that interrupts the command execution loop in runCvc4().
While not a major issue (the binary is terminated anyway in this case, this is also why we label it as feature), we should fix it nevertheless.
This commit makes sure that the current command is properly managed by using `std::unique_ptr` to handle its deletion.
Diffstat (limited to 'src/main/command_executor.cpp')
-rw-r--r-- | src/main/command_executor.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/command_executor.cpp b/src/main/command_executor.cpp index 7081e0f56..d63861b0c 100644 --- a/src/main/command_executor.cpp +++ b/src/main/command_executor.cpp @@ -78,7 +78,7 @@ bool CommandExecutor::doCommand(Command* cmd) } CommandSequence *seq = dynamic_cast<CommandSequence*>(cmd); - if(seq != NULL) { + if(seq != nullptr) { // assume no error bool status = true; @@ -120,24 +120,24 @@ bool CommandExecutor::doCommandSingleton(Command* cmd) if(d_options.getVerbosity() >= -1) { status = smtEngineInvoke(d_smtEngine, cmd, d_options.getOut()); } else { - status = smtEngineInvoke(d_smtEngine, cmd, NULL); + status = smtEngineInvoke(d_smtEngine, cmd, nullptr); } Result res; - CheckSatCommand* cs = dynamic_cast<CheckSatCommand*>(cmd); - if(cs != NULL) { + const CheckSatCommand* cs = dynamic_cast<const CheckSatCommand*>(cmd); + if(cs != nullptr) { d_result = res = cs->getResult(); } - QueryCommand* q = dynamic_cast<QueryCommand*>(cmd); - if(q != NULL) { + const QueryCommand* q = dynamic_cast<const QueryCommand*>(cmd); + if(q != nullptr) { d_result = res = q->getResult(); } - CheckSynthCommand* csy = dynamic_cast<CheckSynthCommand*>(cmd); - if(csy != NULL) { + const CheckSynthCommand* csy = dynamic_cast<const CheckSynthCommand*>(cmd); + if(csy != nullptr) { d_result = res = csy->getResult(); } - if((cs != NULL || q != NULL) && d_options.getStatsEveryQuery()) { + if((cs != nullptr || q != nullptr) && d_options.getStatsEveryQuery()) { std::ostringstream ossCurStats; flushStatistics(ossCurStats); std::ostream& err = *d_options.getErr(); |