From e9370fe5b9dc571c9372465af0295c1b1ea91917 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Wed, 25 Feb 2009 01:54:16 +0000 Subject: [PATCH] Comment the last change --- src/scripting/smjs/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripting/smjs/core.c b/src/scripting/smjs/core.c index 0b2569fb..a921d82a 100644 --- a/src/scripting/smjs/core.c +++ b/src/scripting/smjs/core.c @@ -205,8 +205,8 @@ utf8_to_jsstring(JSContext *ctx, const unsigned char *str, int length) return NULL; } utf16_alloc = in_bytes; - /* Don't use fmem_alloc here because long strings could - * exhaust the stack. */ + /* Use malloc because SpiderMonkey will handle the memory after + * this routine finishes. */ utf16 = malloc(utf16_alloc * sizeof(jschar)); if (utf16 == NULL) { JS_ReportOutOfMemory(ctx); @@ -236,6 +236,8 @@ utf8_to_jsstring(JSContext *ctx, const unsigned char *str, int length) } jsstr = JS_NewUCString(ctx, utf16, utf16_used); + /* Do not free if JS_NewUCString was successful because it takes over + * handling of the memory. */ if (jsstr == NULL) free(utf16); return jsstr;