Don't clobber the default wrapping callback.

This commit is contained in:
Ms2ger 2014-05-06 12:37:13 +02:00
parent 8ea3cbf18a
commit 1fa3610e2d

View file

@ -616,8 +616,16 @@ impl ScriptTask {
ptr.is_not_null()
});
unsafe {
// JS_SetWrapObjectCallbacks clobbers the existing wrap callback,
// and JSCompartment::wrap crashes if that happens. The only way
// to retrieve the default callback is as the result of
// JS_SetWrapObjectCallbacks, which is why we call it twice.
let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr,
ptr::null(),
wrap_for_same_compartment,
ptr::null());
JS_SetWrapObjectCallbacks((*js_runtime).ptr,
ptr::null(),
callback,
wrap_for_same_compartment,
ptr::null());
}