Commit 7cd41c87 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Make sure v8::String::Value and relatives are always initialized.

BUG=1370

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7818 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 465aa7ef
...@@ -4852,26 +4852,19 @@ void Isolate::Exit() { ...@@ -4852,26 +4852,19 @@ void Isolate::Exit() {
} }
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return;
if (obj.IsEmpty()) { if (obj.IsEmpty()) return;
str_ = NULL;
length_ = 0;
return;
}
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
TryCatch try_catch; TryCatch try_catch;
Handle<String> str = obj->ToString(); Handle<String> str = obj->ToString();
if (str.IsEmpty()) { if (str.IsEmpty()) return;
str_ = NULL; length_ = str->Utf8Length();
length_ = 0; str_ = i::NewArray<char>(length_ + 1);
} else { str->WriteUtf8(str_);
length_ = str->Utf8Length();
str_ = i::NewArray<char>(length_ + 1);
str->WriteUtf8(str_);
}
} }
...@@ -4880,26 +4873,19 @@ String::Utf8Value::~Utf8Value() { ...@@ -4880,26 +4873,19 @@ String::Utf8Value::~Utf8Value() {
} }
String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) { String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return;
if (obj.IsEmpty()) { if (obj.IsEmpty()) return;
str_ = NULL;
length_ = 0;
return;
}
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
TryCatch try_catch; TryCatch try_catch;
Handle<String> str = obj->ToString(); Handle<String> str = obj->ToString();
if (str.IsEmpty()) { if (str.IsEmpty()) return;
str_ = NULL; length_ = str->Length();
length_ = 0; str_ = i::NewArray<char>(length_ + 1);
} else { str->WriteAscii(str_);
length_ = str->Length();
str_ = i::NewArray<char>(length_ + 1);
str->WriteAscii(str_);
}
} }
...@@ -4908,26 +4894,19 @@ String::AsciiValue::~AsciiValue() { ...@@ -4908,26 +4894,19 @@ String::AsciiValue::~AsciiValue() {
} }
String::Value::Value(v8::Handle<v8::Value> obj) { String::Value::Value(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return; if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return;
if (obj.IsEmpty()) { if (obj.IsEmpty()) return;
str_ = NULL;
length_ = 0;
return;
}
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
TryCatch try_catch; TryCatch try_catch;
Handle<String> str = obj->ToString(); Handle<String> str = obj->ToString();
if (str.IsEmpty()) { if (str.IsEmpty()) return;
str_ = NULL; length_ = str->Length();
length_ = 0; str_ = i::NewArray<uint16_t>(length_ + 1);
} else { str->Write(str_);
length_ = str->Length();
str_ = i::NewArray<uint16_t>(length_ + 1);
str->Write(str_);
}
} }
......
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