Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: src/ast.cc

Issue 7170014: Avoid OOM on regexps with nested quantifiers. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 bool RegExpCapture::IsAnchoredAtStart() { 918 bool RegExpCapture::IsAnchoredAtStart() {
919 return body()->IsAnchoredAtStart(); 919 return body()->IsAnchoredAtStart();
920 } 920 }
921 921
922 922
923 bool RegExpCapture::IsAnchoredAtEnd() { 923 bool RegExpCapture::IsAnchoredAtEnd() {
924 return body()->IsAnchoredAtEnd(); 924 return body()->IsAnchoredAtEnd();
925 } 925 }
926 926
927 927
928 bool RegExpDisjunction::ContainsExpandedQuantifier() {
929 if (contains_expanded_quantifier_) return true;
930 int len = alternatives_->length();
931 for (int i = 0; i < len; i++) {
932 if (alternatives_->at(i)->ContainsExpandedQuantifier()) return true;
933 }
934 return false;
935 }
936
937
938 bool RegExpAlternative::ContainsExpandedQuantifier() {
939 if (contains_expanded_quantifier_) return true;
940 int len = nodes_->length();
941 for (int i = 0; i < len; i++) {
942 if (nodes_->at(i)->ContainsExpandedQuantifier()) return true;
943 }
944 return false;
945 }
946
947
928 // Convert regular expression trees to a simple sexp representation. 948 // Convert regular expression trees to a simple sexp representation.
929 // This representation should be different from the input grammar 949 // This representation should be different from the input grammar
930 // in as many cases as possible, to make it more difficult for incorrect 950 // in as many cases as possible, to make it more difficult for incorrect
931 // parses to look as correct ones which is likely if the input and 951 // parses to look as correct ones which is likely if the input and
932 // output formats are alike. 952 // output formats are alike.
933 class RegExpUnparser: public RegExpVisitor { 953 class RegExpUnparser: public RegExpVisitor {
934 public: 954 public:
935 RegExpUnparser(); 955 RegExpUnparser();
936 void VisitCharacterRange(CharacterRange that); 956 void VisitCharacterRange(CharacterRange that);
937 SmartPointer<const char> ToString() { return stream_.ToCString(); } 957 SmartPointer<const char> ToString() { return stream_.ToCString(); }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 int pos) 1153 int pos)
1134 : label_(label), 1154 : label_(label),
1135 statements_(statements), 1155 statements_(statements),
1136 position_(pos), 1156 position_(pos),
1137 compare_type_(NONE), 1157 compare_type_(NONE),
1138 compare_id_(AstNode::GetNextId()), 1158 compare_id_(AstNode::GetNextId()),
1139 entry_id_(AstNode::GetNextId()) { 1159 entry_id_(AstNode::GetNextId()) {
1140 } 1160 }
1141 1161
1142 } } // namespace v8::internal 1162 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698