Avoid overallocating JS stack for "%ip" and other multi-char format codes.
git-svn-id: svn://10.0.0.236/trunk@38663 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
44d2ea1fa2
commit
a09150474c
@ -259,6 +259,10 @@ JS_PushArgumentsVA(JSContext *cx, void **markp, const char *format, va_list ap)
|
||||
*markp = NULL;
|
||||
argc = 0;
|
||||
for (cp = format; (c = *cp) != '\0'; cp++) {
|
||||
/*
|
||||
* Count non-space non-star characters as individual jsval arguments.
|
||||
* This may over-allocate stack, but we'll fix below.
|
||||
*/
|
||||
if (isspace(c) || c == '*')
|
||||
continue;
|
||||
argc++;
|
||||
@ -326,6 +330,14 @@ JS_PushArgumentsVA(JSContext *cx, void **markp, const char *format, va_list ap)
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
|
||||
/*
|
||||
* We may have overallocated stack due to a multi-character format code
|
||||
* handled by a JSArgumentFormatter. Give back that stack space!
|
||||
*/
|
||||
JS_ASSERT(sp <= argv + argc);
|
||||
if (sp < argv + argc)
|
||||
cx->stackPool.current->avail = (jsuword)sp;
|
||||
return argv;
|
||||
|
||||
bad:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user