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

Side by Side Diff: src/jsregexp.h

Issue 113894: Added stack overflow check for RegExp analysis phase. (Closed)
Patch Set: Added test for stack overflow Created 11 years, 7 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
« no previous file with comments | « no previous file | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 // result will be something like: 1303 // result will be something like:
1304 // 1304 //
1305 // +-------+ +------------+ 1305 // +-------+ +------------+
1306 // | . | | . | 1306 // | . | | . |
1307 // +-------+ ---> +------------+ 1307 // +-------+ ---> +------------+
1308 // | word? | | check word | 1308 // | word? | | check word |
1309 // +-------+ +------------+ 1309 // +-------+ +------------+
1310 class Analysis: public NodeVisitor { 1310 class Analysis: public NodeVisitor {
1311 public: 1311 public:
1312 explicit Analysis(bool ignore_case) 1312 explicit Analysis(bool ignore_case)
1313 : ignore_case_(ignore_case) { } 1313 : ignore_case_(ignore_case), error_message_(NULL) { }
1314 void EnsureAnalyzed(RegExpNode* node); 1314 void EnsureAnalyzed(RegExpNode* node);
1315 1315
1316 #define DECLARE_VISIT(Type) \ 1316 #define DECLARE_VISIT(Type) \
1317 virtual void Visit##Type(Type##Node* that); 1317 virtual void Visit##Type(Type##Node* that);
1318 FOR_EACH_NODE_TYPE(DECLARE_VISIT) 1318 FOR_EACH_NODE_TYPE(DECLARE_VISIT)
1319 #undef DECLARE_VISIT 1319 #undef DECLARE_VISIT
1320 virtual void VisitLoopChoice(LoopChoiceNode* that); 1320 virtual void VisitLoopChoice(LoopChoiceNode* that);
1321 1321
1322 bool failed() { return error_message_ != NULL; }
Christian Plesner Hansen 2009/05/27 10:04:48 Since this is a boolean predicate it should be 'ha
1323 const char* error_message() {
1324 ASSERT(error_message_ != NULL);
1325 return error_message_;
1326 }
1327 void fail(const char* error_message) {
1328 error_message_ = error_message;
1329 }
1322 private: 1330 private:
1323 bool ignore_case_; 1331 bool ignore_case_;
1332 const char* error_message_;
1324 1333
1325 DISALLOW_IMPLICIT_CONSTRUCTORS(Analysis); 1334 DISALLOW_IMPLICIT_CONSTRUCTORS(Analysis);
1326 }; 1335 };
1327 1336
1328 1337
1329 struct RegExpCompileData { 1338 struct RegExpCompileData {
1330 RegExpCompileData() 1339 RegExpCompileData()
1331 : tree(NULL), 1340 : tree(NULL),
1332 node(NULL), 1341 node(NULL),
1333 simple(true), 1342 simple(true),
(...skipping 30 matching lines...) Expand all
1364 Handle<String> pattern, 1373 Handle<String> pattern,
1365 bool is_ascii); 1374 bool is_ascii);
1366 1375
1367 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); 1376 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
1368 }; 1377 };
1369 1378
1370 1379
1371 } } // namespace v8::internal 1380 } } // namespace v8::internal
1372 1381
1373 #endif // V8_JSREGEXP_H_ 1382 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « no previous file | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698