Bug 617097 part 1. Fix Number.toLocaleString leak. r=brendan
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 09 Dec 2010 16:24:32 -0500
changeset 59027 abef6c3c5dbf2d6a9a75c12d38baf3d673adab54
parent 59026 799ba3224669129a8b96f8550824e870d064a251
child 59028 f971ad6ed5a5c5ba00e745ae75b78b39241496b2
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbrendan
bugs617097
milestone2.0b8pre
Bug 617097 part 1. Fix Number.toLocaleString leak. r=brendan
js/src/jsnum.cpp
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -804,18 +804,21 @@ num_toLocaleString(JSContext *cx, uintN 
     if (*nint == '.') {
         strcpy(tmpDest, rt->decimalSeparator);
         tmpDest += decimalLength;
         strcpy(tmpDest, nint + 1);
     } else {
         strcpy(tmpDest, nint);
     }
 
-    if (cx->localeCallbacks && cx->localeCallbacks->localeToUnicode)
-        return cx->localeCallbacks->localeToUnicode(cx, buf, Jsvalify(vp));
+    if (cx->localeCallbacks && cx->localeCallbacks->localeToUnicode) {
+        JSBool ok = cx->localeCallbacks->localeToUnicode(cx, buf, Jsvalify(vp));
+        cx->free(buf);
+        return ok;
+    }
 
     str = js_NewStringCopyN(cx, buf, size);
     cx->free(buf);
     if (!str)
         return JS_FALSE;
 
     vp->setString(str);
     return JS_TRUE;