Reviewers: Kasper Lund,

Message:
Should we make a unit test using the API to send bad data?

Description:
Prevent invalid pre-parsing data passed in through the API from crashing V8.

Please review this at http://codereview.chromium.org/2876046/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/parser.cc


Index: src/parser.cc
===================================================================
--- src/parser.cc       (revision 5023)
+++ src/parser.cc       (working copy)
@@ -3810,7 +3810,17 @@
     Handle<FixedArray> this_property_assignments;
     if (is_lazily_compiled && pre_data() != NULL) {
       FunctionEntry entry = pre_data()->GetFunctionEnd(start_pos);
+      if (!entry.is_valid()) {
+ ReportMessage("invalid preparser data", Vector<const char*>::empty());
+        *ok = false;
+        return NULL;
+      }
       int end_pos = entry.end_pos();
+ if (end_pos <= start_pos) { // End position too large is safe to pass on. + ReportMessage("invalid preparser data", Vector<const char*>::empty());
+        *ok = false;
+        return NULL;
+      }
       Counters::total_preparse_skipped.Increment(end_pos - start_pos);
       scanner_.SeekForward(end_pos);
       materialized_literal_count = entry.literal_count();


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to