Bug 850873 - Fix null-checking in JS_NewArrayBufferWithContents. r=Waldo

This commit is contained in:
Steve Fink 2013-03-13 14:45:22 -07:00
parent e40b21d88c
commit fb57c0fab7

View File

@ -3725,9 +3725,10 @@ JS_NewArrayBuffer(JSContext *cx, uint32_t nbytes)
JS_PUBLIC_API(JSObject *)
JS_NewArrayBufferWithContents(JSContext *cx, void *contents)
{
if (!contents)
return NULL;
JS_ASSERT(contents);
JSObject *obj = ArrayBufferObject::create(cx, 0);
if (!obj)
return NULL;
obj->setDynamicElements(reinterpret_cast<js::ObjectElements *>(contents));
JS_ASSERT(*GetViewList(&obj->asArrayBuffer()) == NULL);
return obj;