Two little bugs: Destroy the C++ js::Debug object when the JS Debug object is finalized; and generate the right error message when not enough arguments are passed.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 20 May 2011 11:04:12 -0500
changeset 74430 4ab2a31a2b9d4edeb0017413630127744130699f
parent 74429 be12caeb033ae18a50ab90393e80e3eb25d29c96
child 74431 5c58addb72dc2906f1fe1101101a179ff877f6e7
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
Two little bugs: Destroy the C++ js::Debug object when the JS Debug object is finalized; and generate the right error message when not enough arguments are passed.
js/src/jsdbg.cpp
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -69,19 +69,20 @@ enum {
     JSSLOT_DEBUGOBJECT_COUNT
 };
 
 // === Utils
 
 bool
 ReportMoreArgsNeeded(JSContext *cx, const char *name, uintN required)
 {
-    JS_ASSERT(required < 10);
+    JS_ASSERT(required > 0);
+    JS_ASSERT(required <= 10);
     char s[2];
-    s[0] = '0' + required;
+    s[0] = '0' + (required - 1);
     s[1] = '\0';
     JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
                          name, s, required == 1 ? "" : "s");
     return false;
 }
 
 #define REQUIRE_ARGC(name, n) \
     JS_BEGIN_MACRO \
@@ -587,16 +588,17 @@ Debug::sweepCompartment(JSCompartment *c
 }
 
 void
 Debug::finalize(JSContext *cx, JSObject *obj)
 {
     Debug *dbg = (Debug *) obj->getPrivate();
     if (dbg && dbg->debuggeeCompartment)
         dbg->detachFrom(dbg->debuggeeCompartment);
+    cx->delete_(dbg);
 }
 
 void
 Debug::detachFrom(JSCompartment *c)
 {
     JS_ASSERT(c == debuggeeCompartment);
     c->removeDebug(this);
     debuggeeCompartment = NULL;