Fixed regression http://code.google.com/p/v8/issues/detail?id=236.

The problem was that the case of 'undefined' script source wasn't
handled in Script::InitLineEnds.

Review URL: http://codereview.chromium.org/28068

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1350 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent be059966
......@@ -6953,6 +6953,12 @@ Object* Dictionary::TransformPropertiesToFastFor(JSObject* obj,
void Script::InitLineEnds() {
if (!line_ends()->IsUndefined()) return;
if (source()->IsUndefined()) {
set_line_ends(*(Factory::NewArrayLiteral(0)));
ASSERT(line_ends()->IsJSArray());
return;
}
Handle<String> src(String::cast(source()));
const int src_len = src->length();
Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n"));
......
......@@ -302,3 +302,17 @@ TEST(C2JSFrames) {
&has_pending_exception);
CHECK(!has_pending_exception);
}
// Regression 236. Calling InitLineEnds on a Script with undefined
// source resulted in crash.
TEST(Regression236) {
InitializeVM();
v8::HandleScope scope;
Handle<Script> script = Factory::NewScript(Factory::empty_string());
script->set_source(Heap::undefined_value());
CHECK_EQ(-1, script->GetLineNumber(0));
CHECK_EQ(-1, script->GetLineNumber(100));
CHECK_EQ(-1, script->GetLineNumber(-1));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment