Bug 1253059: Use fallible allocation in the worker error reporter. r=baku

This commit is contained in:
Kyle Huey 2016-03-10 01:50:56 -08:00
parent 9eea75a6f5
commit d7b4ab4573

View File

@ -5795,7 +5795,13 @@ WorkerPrivate::ReportError(JSContext* aCx, const char* aFallbackMessage,
}
if (message.IsEmpty()) {
message = NS_ConvertUTF8toUTF16(aFallbackMessage);
nsDependentCString fallbackMessage(aFallbackMessage);
if (!AppendUTF8toUTF16(fallbackMessage, message, mozilla::fallible)) {
// Try again, with only a 1 KB string. Do this infallibly this time.
// If the user doesn't have 1 KB to spare we're done anyways.
nsDependentCString truncatedFallbackMessage(aFallbackMessage, 1024);
AppendUTF8toUTF16(truncatedFallbackMessage, message);
}
}
mErrorHandlerRecursionCount++;