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

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

Issue 1369773004: IndexedDB: Fix null ptr crash in IDBCursor::value(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added regression layout test. 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
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 294 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 || value->isNull()) 315 if (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 || value->isNull()) 327 if (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

Powered by Google App Engine
This is Rietveld 408576698