From 7067fc7af9fb3af98c09f5b98632c9ef90849b8e Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 8 Feb 2009 23:07:22 +0200 Subject: [PATCH] Check for JS_ReportAllocationOverflow before using it. Debian libmozjs-dev 1.9.0.4-2 has JS_ReportAllocationOverflow but js-1.7.0 reportedly hasn't. Check at configure time whether that function is available. If not, use JS_ReportOutOfMemory instead. Reported by Witold Filipczyk. --- configure.in | 3 +++ src/scripting/smjs/core.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/configure.in b/configure.in index 27c7a847..d32e691d 100644 --- a/configure.in +++ b/configure.in @@ -629,6 +629,9 @@ fi AC_MSG_RESULT($cf_result) CONFIG_SPIDERMONKEY="$cf_result" +if test "$cf_result" = "yes"; then + AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]]) +fi EL_RESTORE_FLAGS if test "x$CONFIG_SPIDERMONKEY" = xyes && diff --git a/src/scripting/smjs/core.c b/src/scripting/smjs/core.c index 57a8eb41..4582da3a 100644 --- a/src/scripting/smjs/core.c +++ b/src/scripting/smjs/core.c @@ -195,7 +195,11 @@ utf8_to_jsstring(JSContext *ctx, const unsigned char *str, int length) * Check whether the multiplication could overflow. */ assert(!needs_utf16_surrogates(UCS_REPLACEMENT_CHARACTER)); if (in_bytes > ((size_t) -1) / sizeof(jschar)) { +#ifdef HAVE_JS_REPORTALLOCATIONOVERFLOW JS_ReportAllocationOverflow(ctx); +#else + JS_ReportOutOfMemory(ctx); +#endif return NULL; } utf16_alloc = in_bytes; -- 2.11.4.GIT