Commit 712beaa8 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

gin: fix crash on concat strings passed to ThrowError

V8TypeAsString was passing nullptr to the ConvertFromV8 function, so now
we always pass the isolate. Also adds a DCHECK to ensure that V8ToString
to ConvertFromV8 to ensure it's always passed a non-null Isolate.

Bug: 866767
Change-Id: I715396f309a0c49e4c6bc6ade14b5f0aad8befec
Reviewed-on: https://chromium-review.googlesource.com/1148209Reviewed-by: default avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577597}
parent 1f091472
......@@ -48,7 +48,7 @@ v8::Local<v8::Context> Arguments::GetHolderCreationContext() {
return info_->Holder()->CreationContext();
}
std::string V8TypeAsString(v8::Local<v8::Value> value) {
std::string V8TypeAsString(v8::Isolate* isolate, v8::Local<v8::Value> value) {
if (value.IsEmpty())
return "<empty handle>";
if (value->IsUndefined())
......@@ -56,7 +56,7 @@ std::string V8TypeAsString(v8::Local<v8::Value> value) {
if (value->IsNull())
return "null";
std::string result;
if (!ConvertFromV8(NULL, value, &result))
if (!ConvertFromV8(isolate, value, &result))
return std::string();
return result;
}
......@@ -67,7 +67,7 @@ void Arguments::ThrowError() const {
return ThrowTypeError(base::StringPrintf(
"Error processing argument at index %d, conversion failure from %s",
next_ - 1, V8TypeAsString((*info_)[next_ - 1]).c_str()));
next_ - 1, V8TypeAsString(isolate_, (*info_)[next_ - 1]).c_str()));
}
void Arguments::ThrowTypeError(const std::string& message) const {
......
......@@ -255,6 +255,7 @@ GIN_EXPORT v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
template<typename T>
bool ConvertFromV8(v8::Isolate* isolate, v8::Local<v8::Value> input,
T* result) {
DCHECK(isolate);
return Converter<T>::FromV8(isolate, input, result);
}
......
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