Chromium Code Reviews| Index: src/inspector/StringUtil.cpp |
| diff --git a/src/inspector/StringUtil.cpp b/src/inspector/StringUtil.cpp |
| index 04b9e85c8f471566541cc27f5fb0d7b2f46e9fa1..730fc97e2d575b947bd31714c2604b07f2713b51 100644 |
| --- a/src/inspector/StringUtil.cpp |
| +++ b/src/inspector/StringUtil.cpp |
| @@ -103,7 +103,8 @@ std::unique_ptr<protocol::Value> parseJSON(const String16& string) { |
| } // namespace protocol |
| -std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, |
| +std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString, |
| + v8::Local<v8::Context> context, |
| v8::Local<v8::Value> value, |
| int maxDepth) { |
| if (value.IsEmpty()) { |
| @@ -111,7 +112,10 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, |
| return nullptr; |
| } |
| - if (!maxDepth) return nullptr; |
| + if (!maxDepth) { |
| + *errorString = "Object has too long reference chain"; |
|
alph
2016/09/21 02:05:59
nit: Object reference chain is too long.
kozy
2016/09/21 05:12:47
Done.
|
| + return nullptr; |
| + } |
| maxDepth--; |
| if (value->IsNull() || value->IsUndefined()) return protocol::Value::null(); |
| @@ -134,9 +138,12 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, |
| uint32_t length = array->Length(); |
| for (uint32_t i = 0; i < length; i++) { |
| v8::Local<v8::Value> value; |
| - if (!array->Get(context, i).ToLocal(&value)) return nullptr; |
| + if (!array->Get(context, i).ToLocal(&value)) { |
| + *errorString = "Internal error"; |
| + return nullptr; |
| + } |
| std::unique_ptr<protocol::Value> element = |
| - toProtocolValue(context, value, maxDepth); |
| + toProtocolValue(errorString, context, value, maxDepth); |
| if (!element) return nullptr; |
| inspectorArray->pushValue(std::move(element)); |
| } |
| @@ -147,12 +154,17 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, |
| protocol::DictionaryValue::create(); |
| v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); |
| v8::Local<v8::Array> propertyNames; |
| - if (!object->GetPropertyNames(context).ToLocal(&propertyNames)) |
| + if (!object->GetPropertyNames(context).ToLocal(&propertyNames)) { |
| + *errorString = "Internal error"; |
| return nullptr; |
| + } |
| uint32_t length = propertyNames->Length(); |
| for (uint32_t i = 0; i < length; i++) { |
| v8::Local<v8::Value> name; |
| - if (!propertyNames->Get(context, i).ToLocal(&name)) return nullptr; |
| + if (!propertyNames->Get(context, i).ToLocal(&name)) { |
| + *errorString = "Internal error"; |
| + return nullptr; |
| + } |
| // FIXME(yurys): v8::Object should support GetOwnPropertyNames |
| if (name->IsString()) { |
| v8::Maybe<bool> hasRealNamedProperty = object->HasRealNamedProperty( |
| @@ -163,16 +175,19 @@ std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, |
| v8::Local<v8::String> propertyName; |
| if (!name->ToString(context).ToLocal(&propertyName)) continue; |
| v8::Local<v8::Value> property; |
| - if (!object->Get(context, name).ToLocal(&property)) return nullptr; |
| + if (!object->Get(context, name).ToLocal(&property)) { |
| + *errorString = "Internal error"; |
| + return nullptr; |
| + } |
| std::unique_ptr<protocol::Value> propertyValue = |
| - toProtocolValue(context, property, maxDepth); |
| + toProtocolValue(errorString, context, property, maxDepth); |
| if (!propertyValue) return nullptr; |
| jsonObject->setValue(toProtocolString(propertyName), |
| std::move(propertyValue)); |
| } |
| return std::move(jsonObject); |
| } |
| - UNREACHABLE(); |
| + *errorString = "Object couldn't be returned by value"; |
| return nullptr; |
| } |