Index: src/ast/ast.h |
diff --git a/src/ast/ast.h b/src/ast/ast.h |
index b4f2992e047215ac95d2c61b96a98d64afbfb5a1..6a0393cb6cd76b7f12dca3840915ae727dafd8e5 100644 |
--- a/src/ast/ast.h |
+++ b/src/ast/ast.h |
@@ -3186,14 +3186,9 @@ class RegExpBackReference final : public RegExpTree { |
RegExpBackReference* AsBackReference() override; |
bool IsBackReference() override; |
int min_match() override { return 0; } |
- // The capture may not be completely parsed yet, if the reference occurs |
- // before the capture. In the ordinary case, nothing has been captured yet, |
- // so the back reference must have the length 0. If the back reference is |
- // inside a lookbehind, effectively making it a forward reference, we return |
- // 0 since lookbehinds have a length of 0. |
- int max_match() override { |
- return capture_->body() ? capture_->max_match() : 0; |
- } |
+ // The back reference may be recursive, e.g. /(\2)(\1)/. To avoid infinite |
+ // recursion, we give up. Ignorance is bliss. |
+ int max_match() override { return kInfinity; } |
int index() { return capture_->index(); } |
RegExpCapture* capture() { return capture_; } |
private: |