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
This commit is contained in:
parent
465aa7ef08
commit
7cd41c875d
63
src/api.cc
63
src/api.cc
@ -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();
|
||||
if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return;
|
||||
if (obj.IsEmpty()) {
|
||||
str_ = NULL;
|
||||
length_ = 0;
|
||||
return;
|
||||
}
|
||||
if (obj.IsEmpty()) return;
|
||||
ENTER_V8(isolate);
|
||||
i::HandleScope scope(isolate);
|
||||
TryCatch try_catch;
|
||||
Handle<String> str = obj->ToString();
|
||||
if (str.IsEmpty()) {
|
||||
str_ = NULL;
|
||||
length_ = 0;
|
||||
} else {
|
||||
length_ = str->Utf8Length();
|
||||
str_ = i::NewArray<char>(length_ + 1);
|
||||
str->WriteUtf8(str_);
|
||||
}
|
||||
if (str.IsEmpty()) return;
|
||||
length_ = str->Utf8Length();
|
||||
str_ = i::NewArray<char>(length_ + 1);
|
||||
str->WriteUtf8(str_);
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return;
|
||||
if (obj.IsEmpty()) {
|
||||
str_ = NULL;
|
||||
length_ = 0;
|
||||
return;
|
||||
}
|
||||
if (obj.IsEmpty()) return;
|
||||
ENTER_V8(isolate);
|
||||
i::HandleScope scope(isolate);
|
||||
TryCatch try_catch;
|
||||
Handle<String> str = obj->ToString();
|
||||
if (str.IsEmpty()) {
|
||||
str_ = NULL;
|
||||
length_ = 0;
|
||||
} else {
|
||||
length_ = str->Length();
|
||||
str_ = i::NewArray<char>(length_ + 1);
|
||||
str->WriteAscii(str_);
|
||||
}
|
||||
if (str.IsEmpty()) return;
|
||||
length_ = str->Length();
|
||||
str_ = i::NewArray<char>(length_ + 1);
|
||||
str->WriteAscii(str_);
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return;
|
||||
if (obj.IsEmpty()) {
|
||||
str_ = NULL;
|
||||
length_ = 0;
|
||||
return;
|
||||
}
|
||||
if (obj.IsEmpty()) return;
|
||||
ENTER_V8(isolate);
|
||||
i::HandleScope scope(isolate);
|
||||
TryCatch try_catch;
|
||||
Handle<String> str = obj->ToString();
|
||||
if (str.IsEmpty()) {
|
||||
str_ = NULL;
|
||||
length_ = 0;
|
||||
} else {
|
||||
length_ = str->Length();
|
||||
str_ = i::NewArray<uint16_t>(length_ + 1);
|
||||
str->Write(str_);
|
||||
}
|
||||
if (str.IsEmpty()) return;
|
||||
length_ = str->Length();
|
||||
str_ = i::NewArray<uint16_t>(length_ + 1);
|
||||
str->Write(str_);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user