Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp

Issue 1360163003: IndexedDB: Added null value check to fix crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return v8Undefined(); 112 return v8Undefined();
113 } 113 }
114 return array; 114 return array;
115 } 115 }
116 } 116 }
117 117
118 ASSERT_NOT_REACHED(); 118 ASSERT_NOT_REACHED();
119 return v8Undefined(); 119 return v8Undefined();
120 } 120 }
121 121
122 // IDBAny is a a variant type used to hold the values produced by the |result| 122 // IDBAny is a variant type used to hold the values produced by the |result|
123 // attribute of IDBRequest and (as a convenience) the |source| attribute of 123 // attribute of IDBRequest and (as a convenience) the |source| attribute of
124 // IDBRequest and IDBCursor. 124 // IDBRequest and IDBCursor.
125 // TODO(jsbell): Replace the use of IDBAny for |source| attributes (which are 125 // TODO(jsbell): Replace the use of IDBAny for |source| attributes (which are
126 // ScriptWrappable types) using unions per IDL. 126 // ScriptWrappable types) using unions per IDL.
127 v8::Local<v8::Value> toV8(const IDBAny* impl, v8::Local<v8::Object> creationCont ext, v8::Isolate* isolate) 127 v8::Local<v8::Value> toV8(const IDBAny* impl, v8::Local<v8::Object> creationCont ext, v8::Isolate* isolate)
128 { 128 {
129 if (!impl) 129 if (!impl)
130 return v8::Null(isolate); 130 return v8::Null(isolate);
131 131
132 switch (impl->type()) { 132 switch (impl->type()) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 ASSERT(keyPath.type() == IDBKeyPath::StringType); 306 ASSERT(keyPath.type() == IDBKeyPath::StringType);
307 return createIDBKeyFromValueAndKeyPath(isolate, value, keyPath.string(), exc eptionState, allowExperimentalTypes); 307 return createIDBKeyFromValueAndKeyPath(isolate, value, keyPath.string(), exc eptionState, allowExperimentalTypes);
308 } 308 }
309 309
310 // Deserialize just the value data & blobInfo from the given IDBValue. 310 // Deserialize just the value data & blobInfo from the given IDBValue.
311 // Does not deserialize the key & keypath. 311 // Does not deserialize the key & keypath.
312 static v8::Local<v8::Value> deserializeIDBValueData(v8::Isolate* isolate, const IDBValue* value) 312 static v8::Local<v8::Value> deserializeIDBValueData(v8::Isolate* isolate, const IDBValue* value)
313 { 313 {
314 ASSERT(isolate->InContext()); 314 ASSERT(isolate->InContext());
315 if (value->isNull()) 315 if (!value || value->isNull())
316 return v8::Null(isolate); 316 return v8::Null(isolate);
317 317
318 const SharedBuffer* valueData = value->data(); 318 const SharedBuffer* valueData = value->data();
319 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValueFactory ::instance().createFromWireBytes(valueData->data(), valueData->size()); 319 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValueFactory ::instance().createFromWireBytes(valueData->data(), valueData->size());
320 return serializedValue->deserialize(isolate, nullptr, value->blobInfo()); 320 return serializedValue->deserialize(isolate, nullptr, value->blobInfo());
321 } 321 }
322 322
323 // Deserialize the entire IDBValue (injecting key & keypath if present). 323 // Deserialize the entire IDBValue (injecting key & keypath if present).
324 static v8::Local<v8::Value> deserializeIDBValue(v8::Isolate* isolate, v8::Local< v8::Object> creationContext, const IDBValue* value) 324 static v8::Local<v8::Value> deserializeIDBValue(v8::Isolate* isolate, v8::Local< v8::Object> creationContext, const IDBValue* value)
325 { 325 {
326 ASSERT(isolate->InContext()); 326 ASSERT(isolate->InContext());
327 if (value->isNull()) 327 if (!value || value->isNull())
328 return v8::Null(isolate); 328 return v8::Null(isolate);
329 329
330 v8::Local<v8::Value> v8Value = deserializeIDBValueData(isolate, value); 330 v8::Local<v8::Value> v8Value = deserializeIDBValueData(isolate, value);
331 if (value->primaryKey()) { 331 if (value->primaryKey()) {
332 v8::Local<v8::Value> key = toV8(value->primaryKey(), creationContext, is olate); 332 v8::Local<v8::Value> key = toV8(value->primaryKey(), creationContext, is olate);
333 if (key.IsEmpty()) 333 if (key.IsEmpty())
334 return v8::Local<v8::Value>(); 334 return v8::Local<v8::Value>();
335 bool injected = injectV8KeyIntoV8Value(isolate, key, v8Value, value->key Path()); 335 bool injected = injectV8KeyIntoV8Value(isolate, key, v8Value, value->key Path());
336 ASSERT_UNUSED(injected, injected); 336 ASSERT_UNUSED(injected, injected);
337 } 337 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 ASSERT(!exceptionState.hadException()); 511 ASSERT(!exceptionState.hadException());
512 if (expectedKey && expectedKey->isEqual(value->primaryKey())) 512 if (expectedKey && expectedKey->isEqual(value->primaryKey()))
513 return; 513 return;
514 514
515 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa lue.v8Value(), value->keyPath()); 515 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa lue.v8Value(), value->keyPath());
516 ASSERT_UNUSED(injected, injected); 516 ASSERT_UNUSED(injected, injected);
517 } 517 }
518 #endif 518 #endif
519 519
520 } // namespace blink 520 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698