Bug 1282795 - Don't make the last non-ellipsis argument to ExpandErrorArgumentsVA an enumeration that would be subject to integral promotion, because this would invoke undefined behavior. r=froydnj

--HG--
extra : rebase_source : 89910f1ea6811b6bb8553f4d60342cb4aa7e397a
This commit is contained in:
Jeff Walden 2016-06-28 17:11:01 +01:00
Родитель 354825efdd
Коммит b29c07c2ea
4 изменённых файлов: 12 добавлений и 12 удалений

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

@ -652,7 +652,7 @@ TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigne
err.argumentsType = (flags & JSREPORT_UC) ? ArgumentsAreUnicode : ArgumentsAreASCII;
if (!ExpandErrorArgumentsVA(cx, GetErrorMessage, nullptr, errorNumber, &err.message,
&err.report, err.argumentsType, args))
err.argumentsType, &err.report, args))
{
return false;
}

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

@ -484,8 +484,8 @@ js::PrintError(JSContext* cx, FILE* file, const char* message, JSErrorReport* re
bool
js::ExpandErrorArgumentsVA(ExclusiveContext* cx, JSErrorCallback callback,
void* userRef, const unsigned errorNumber,
char** messagep, JSErrorReport* reportp,
ErrorArgumentsType argumentsType, va_list ap)
char** messagep, ErrorArgumentsType argumentsType,
JSErrorReport* reportp, va_list ap)
{
const JSErrorFormatString* efs;
uint16_t argCount;
@ -665,7 +665,7 @@ js::ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback,
PopulateReportBlame(cx, &report);
if (!ExpandErrorArgumentsVA(cx, callback, userRef, errorNumber,
&message, &report, argumentsType, ap)) {
&message, argumentsType, &report, ap)) {
return false;
}
@ -692,13 +692,13 @@ js::ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback,
static bool
ExpandErrorArguments(ExclusiveContext* cx, JSErrorCallback callback,
void* userRef, const unsigned errorNumber,
char** messagep, JSErrorReport* reportp,
ErrorArgumentsType argumentsType, ...)
char** messagep, ErrorArgumentsType argumentsType,
JSErrorReport* reportp, ...)
{
va_list ap;
va_start(ap, argumentsType);
va_start(ap, reportp);
bool expanded = js::ExpandErrorArgumentsVA(cx, callback, userRef, errorNumber,
messagep, reportp, argumentsType, ap);
messagep, argumentsType, reportp, ap);
va_end(ap);
return expanded;
}
@ -720,7 +720,7 @@ js::ReportErrorNumberUCArray(JSContext* cx, unsigned flags, JSErrorCallback call
char* message;
if (!ExpandErrorArguments(cx, callback, userRef, errorNumber,
&message, &report, ArgumentsAreUnicode)) {
&message, ArgumentsAreUnicode, &report)) {
return false;
}

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

@ -547,8 +547,8 @@ ReportErrorNumberUCArray(JSContext* cx, unsigned flags, JSErrorCallback callback
extern bool
ExpandErrorArgumentsVA(ExclusiveContext* cx, JSErrorCallback callback,
void* userRef, const unsigned errorNumber,
char** message, JSErrorReport* reportp,
ErrorArgumentsType argumentsType, va_list ap);
char** message, ErrorArgumentsType argumentsType,
JSErrorReport* reportp, va_list ap);
/* |callee| requires a usage string provided by JS_DefineFunctionsWithHelp. */
extern void

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

@ -944,7 +944,7 @@ ErrorReport::populateUncaughtExceptionReportVA(JSContext* cx, va_list ap)
if (!ExpandErrorArgumentsVA(cx, GetErrorMessage, nullptr,
JSMSG_UNCAUGHT_EXCEPTION, &ownedMessage,
&ownedReport, ArgumentsAreASCII, ap)) {
ArgumentsAreASCII, &ownedReport, ap)) {
return false;
}