Bug 935173 - Fix JS_NeuterArrayBuffer and call it, r=Waldo

--HG--
extra : rebase_source : 974ec3f776849382fe7684117c647013f7e14236
This commit is contained in:
Steve Fink 2013-11-05 14:42:16 -08:00
parent 3f9be57384
commit 565e5e83ac
3 changed files with 7 additions and 13 deletions

View File

@ -1326,13 +1326,7 @@ Neuter(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
void *contents;
uint8_t *data;
if (!JS_StealArrayBufferContents(cx, obj, &contents, &data))
return false;
js_free(contents);
return true;
return JS_NeuterArrayBuffer(cx, obj);
}
static const JSFunctionSpecWithHelp TestingFunctions[] = {

View File

@ -1248,8 +1248,8 @@ JS_GetArrayBufferViewBuffer(JSObject *obj);
/*
* Set an ArrayBuffer's length to 0 and neuter all of its views.
*/
extern JS_FRIEND_API(void)
JS_NeuterArrayBuffer(JSObject *obj, JSContext *cx);
extern JS_FRIEND_API(bool)
JS_NeuterArrayBuffer(JSContext *cx, JS::HandleObject obj);
/*
* Check whether obj supports JS_GetDataView* APIs.

View File

@ -4031,12 +4031,12 @@ JS_GetArrayBufferData(JSObject *obj)
}
JS_FRIEND_API(bool)
JS_NeuterArrayBuffer(JSContext *cx, JSObject *obj)
JS_NeuterArrayBuffer(JSContext *cx, HandleObject obj)
{
ArrayBufferObject &buffer = obj->as<ArrayBufferObject>();
if (!buffer.neuterViews(cx))
Rooted<ArrayBufferObject*> buffer(cx, &obj->as<ArrayBufferObject>());
if (!buffer->neuterViews(cx))
return false;
buffer.neuter(cx);
buffer->neuter(cx);
return true;
}