From be5d94c4a1dac6e29e7a8477438b9affd5ae7347 Mon Sep 17 00:00:00 2001 From: "khanson%netscape.com" Date: Fri, 15 Mar 2002 00:11:44 +0000 Subject: [PATCH] bug #130711, r=khanson, sr=brendan, a=asa, memory leak in JS_dtoa --- js/src/jsdtoa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/src/jsdtoa.c b/js/src/jsdtoa.c index 09b19cf3e808..0db7ded49b25 100644 --- a/js/src/jsdtoa.c +++ b/js/src/jsdtoa.c @@ -1926,6 +1926,7 @@ JS_dtoa(double d, int mode, JSBool biasUp, int ndigits, } return JS_TRUE; } + b = NULL; /* initialize for abort protection */ if (!d) { no_digits: *decpt = 1; @@ -1937,6 +1938,9 @@ JS_dtoa(double d, int mode, JSBool biasUp, int ndigits, buf[0] = '0'; buf[1] = '\0'; /* copy "0" to buffer */ if (rve) *rve = buf + 1; + /* We might have jumped to "no_digits" from below, so we need + * to be sure to free "b" to avoid memory leaks. */ + Bfree(b); return JS_TRUE; }