diff --git a/runtime/Cpp/runtime/src/NoViableAltException.cpp b/runtime/Cpp/runtime/src/NoViableAltException.cpp
index ced7f82..75bec5d 100755
--- a/runtime/Cpp/runtime/src/NoViableAltException.cpp
+++ b/runtime/Cpp/runtime/src/NoViableAltException.cpp
@@ -21,8 +21,6 @@ NoViableAltException::NoViableAltException(Parser *recognizer, TokenStream *inpu
}
NoViableAltException::~NoViableAltException() {
- if (_deleteConfigs)
- delete _deadEndConfigs;
}
Token* NoViableAltException::getStartToken() const {
@@ -30,5 +28,5 @@ Token* NoViableAltException::getStartToken() const {
}
atn::ATNConfigSet* NoViableAltException::getDeadEndConfigs() const {
- return _deadEndConfigs;
+ return _deadEndConfigs.get();
}
diff --git a/runtime/Cpp/runtime/src/NoViableAltException.h b/runtime/Cpp/runtime/src/NoViableAltException.h
index 94d43c5..f3f1fe7 100755
--- a/runtime/Cpp/runtime/src/NoViableAltException.h
+++ b/runtime/Cpp/runtime/src/NoViableAltException.h
@@ -27,7 +27,7 @@ namespace antlr4 {
private:
/// Which configurations did we try at input.index() that couldn't match input.LT(1)?
- atn::ATNConfigSet* _deadEndConfigs;
+ std::shared_ptr<atn::ATNConfigSet> _deadEndConfigs;
// Flag that indicates if we own the dead end config set and have to delete it on destruction.
bool _deleteConfigs;
This applies the following patch to ANTLR:
fixes #2