Bug 942480: Don't js_delete a freshly allocated js::Debugger, if we've stored it in the Debugger JSObject's private slot. r=shu

This commit is contained in:
Jim Blandy 2013-12-08 15:53:28 -08:00
parent 19850f7261
commit 8a825633a5

View File

@ -2126,14 +2126,16 @@ Debugger::construct(JSContext *cx, unsigned argc, Value *vp)
for (unsigned slot = JSSLOT_DEBUG_PROTO_START; slot < JSSLOT_DEBUG_PROTO_STOP; slot++)
obj->setReservedSlot(slot, proto->getReservedSlot(slot));
/* Construct the underlying C++ object. */
Debugger *dbg = cx->new_<Debugger>(cx, obj.get());
if (!dbg)
return false;
obj->setPrivate(dbg);
if (!dbg->init(cx)) {
js_delete(dbg);
return false;
}
obj->setPrivate(dbg);
/* Now the JSObject owns the js::Debugger instance, so we needn't delete it. */
/* Add the initial debuggees, if any. */
for (unsigned i = 0; i < argc; i++) {