Bug 1196391, part 2 - Add JSAPI constant for the max number of error arguments. r=Waldo

This will allow users of the API to do checking of values they pass in.
This commit is contained in:
Andrew McCreight 2015-09-03 15:39:08 -07:00
Родитель 7f296622e0
Коммит 6016fb539e
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -4478,6 +4478,10 @@ JS_GetLocaleCallbacks(JSRuntime* rt);
* Error reporting.
*/
namespace JS {
const uint16_t MaxNumErrorArguments = 10;
};
/*
* Report an exception represented by the sprintf-like conversion of format
* and its arguments. This exception message string is passed to a pre-set

Просмотреть файл

@ -582,9 +582,9 @@ js::ExpandErrorArgumentsVA(ExclusiveContext* cx, JSErrorCallback callback,
reportp->exnType = efs->exnType;
size_t totalArgsLength = 0;
size_t argLengths[10]; /* only {0} thru {9} supported */
size_t argLengths[JS::MaxNumErrorArguments]; /* only {0} thru {9} supported */
argCount = efs->argCount;
MOZ_ASSERT(argCount <= 10);
MOZ_ASSERT(argCount <= JS::MaxNumErrorArguments);
if (argCount > 0) {
/*
* Gather the arguments into an array, and accumulate