зеркало из https://github.com/mozilla/pjs.git
bug=422348 r,a1.9=shaver proper overflow error reporting
This commit is contained in:
Родитель
bf79507b72
Коммит
75f123288e
|
@ -85,7 +85,7 @@ MSG_DEF(JSMSG_INACTIVE, 2, 0, JSEXN_INTERNALERR, "nothing active
|
|||
MSG_DEF(JSMSG_MORE_ARGS_NEEDED, 3, 3, JSEXN_TYPEERR, "{0} requires more than {1} argument{2}")
|
||||
MSG_DEF(JSMSG_BAD_CHAR, 4, 1, JSEXN_INTERNALERR, "invalid format character {0}")
|
||||
MSG_DEF(JSMSG_BAD_TYPE, 5, 1, JSEXN_TYPEERR, "unknown type {0}")
|
||||
MSG_DEF(JSMSG_UNUSED6, 6, 0, JSEXN_NONE, "")
|
||||
MSG_DEF(JSMSG_ALLOC_OVERFLOW, 6, 0, JSEXN_INTERNALERR, "allocation size overflow")
|
||||
MSG_DEF(JSMSG_CANT_UNLOCK, 7, 0, JSEXN_INTERNALERR, "can't unlock memory")
|
||||
MSG_DEF(JSMSG_INCOMPATIBLE_PROTO, 8, 3, JSEXN_TYPEERR, "{0}.prototype.{1} called on incompatible {2}")
|
||||
MSG_DEF(JSMSG_NO_CONSTRUCTOR, 9, 1, JSEXN_TYPEERR, "{0} has no constructor")
|
||||
|
|
|
@ -5524,6 +5524,12 @@ JS_ReportOutOfMemory(JSContext *cx)
|
|||
js_ReportOutOfMemory(cx);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_ReportAllocationOverflow(JSContext *cx)
|
||||
{
|
||||
js_ReportAllocationOverflow(cx);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSErrorReporter)
|
||||
JS_SetErrorReporter(JSContext *cx, JSErrorReporter er)
|
||||
{
|
||||
|
|
|
@ -2467,6 +2467,12 @@ JS_ReportErrorFlagsAndNumberUC(JSContext *cx, uintN flags,
|
|||
extern JS_PUBLIC_API(void)
|
||||
JS_ReportOutOfMemory(JSContext *cx);
|
||||
|
||||
/*
|
||||
* Complain when an allocation size overflows the maximum supported limit.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ReportAllocationOverflow(JSContext *cx);
|
||||
|
||||
struct JSErrorReport {
|
||||
const char *filename; /* source file name, URL, etc., or null */
|
||||
uintN lineno; /* source line number */
|
||||
|
|
|
@ -329,7 +329,7 @@ ResizeSlots(JSContext *cx, JSObject *obj, uint32 oldlen, uint32 len)
|
|||
}
|
||||
|
||||
if (len > ~(uint32)0 / sizeof(jsval)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1798,7 +1798,7 @@ array_sort(JSContext *cx, uintN argc, jsval *vp)
|
|||
*/
|
||||
#if JS_BITS_PER_WORD == 32
|
||||
if ((size_t)len > ~(size_t)0 / (2 * sizeof(jsval))) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
@ -1902,7 +1902,7 @@ array_sort(JSContext *cx, uintN argc, jsval *vp)
|
|||
*/
|
||||
#if JS_BITS_PER_WORD == 32
|
||||
if ((size_t)newlen > ~(size_t)0 / (4 * sizeof(jsval))) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -929,6 +929,12 @@ js_ReportOverRecursed(JSContext *cx)
|
|||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_OVER_RECURSED);
|
||||
}
|
||||
|
||||
void
|
||||
js_ReportAllocationOverflow(JSContext *cx)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_ALLOC_OVERFLOW);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap)
|
||||
{
|
||||
|
|
|
@ -993,6 +993,9 @@ js_ReportOutOfScriptQuota(JSContext *cx);
|
|||
extern void
|
||||
js_ReportOverRecursed(JSContext *cx);
|
||||
|
||||
extern void
|
||||
js_ReportAllocationOverflow(JSContext *cx);
|
||||
|
||||
#define JS_CHECK_RECURSION(cx, onerror) \
|
||||
JS_BEGIN_MACRO \
|
||||
int stackDummy_; \
|
||||
|
|
|
@ -296,7 +296,7 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
|
|||
overflow |= (valueCount > ((size_t)-1 - size) / sizeof(jsval));
|
||||
size += valueCount * sizeof(jsval);
|
||||
if (overflow) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
priv = (JSExnPrivate *)JS_malloc(cx, size);
|
||||
|
|
|
@ -1801,7 +1801,7 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
old_args_length = args_length;
|
||||
args_length = old_args_length + JSSTRING_LENGTH(arg);
|
||||
if (args_length < old_args_length) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1811,7 +1811,7 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
args_length = old_args_length + n - 1;
|
||||
if (args_length < old_args_length ||
|
||||
args_length >= ~(size_t)0 / sizeof(jschar)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -352,13 +352,13 @@ js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||
* most 5 on each iteration.
|
||||
*/
|
||||
if (newlength < length) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (newlength >= ~(size_t)0 / sizeof(jschar)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -2068,7 +2068,7 @@ tagify(JSContext *cx, const char *begin, JSString *param, const char *end,
|
|||
taglen += JSSTRING_LENGTH(str) + 2 + endlen + 1; /* 'str</end>' */
|
||||
|
||||
if (taglen >= ~(size_t)0 / sizeof(jschar)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -2461,7 +2461,7 @@ js_NewString(JSContext *cx, jschar *chars, size_t length)
|
|||
JSString *str;
|
||||
|
||||
if (length > JSSTRING_LENGTH_MASK) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -2367,7 +2367,7 @@ EscapeElementValue(JSContext *cx, JSStringBuffer *sb, JSString *str)
|
|||
newlength += 4;
|
||||
|
||||
if (newlength < length) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2424,7 +2424,7 @@ EscapeAttributeValue(JSContext *cx, JSStringBuffer *sb, JSString *str,
|
|||
newlength += 4;
|
||||
|
||||
if (newlength < length) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче