Remove memory leak in ConditionalCommand (#537)

This also properly handles nullptrs passed into ConditionalCommand
instead of having Undefined Behavior or NullPointerExceptions.
This commit is contained in:
Chris Gregory
2017-06-30 22:01:21 -07:00
committed by Peter Johnson
parent 4fd4a50d41
commit d2de94778e
3 changed files with 49 additions and 32 deletions

View File

@@ -40,10 +40,9 @@ namespace frc {
*/
class ConditionalCommand : public Command {
public:
explicit ConditionalCommand(Command* onTrue,
Command* onFalse = new InstantCommand());
explicit ConditionalCommand(Command* onTrue, Command* onFalse = nullptr);
ConditionalCommand(const std::string& name, Command* onTrue,
Command* onFalse = new InstantCommand());
Command* onFalse = nullptr);
virtual ~ConditionalCommand() = default;
protected: