empirical-soft / empirical-lang

A language for time-series analysis
https://www.empirical-soft.com/
Other
168 stars 13 forks source link

Fixed ANTLR bug that was causing parse error to result in crash #17

Closed chrisaycock closed 5 years ago

chrisaycock commented 5 years ago

This applies the following patch to ANTLR:

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;

fixes #2