diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index a4912c349b10..6c0547a84185 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -8808,14 +8808,14 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler, interval = NS_MAX(aIsInterval ? 1 : 0, interval); // Make sure we don't proceed with an interval larger than our timer - // code can handle. - if (interval > PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE)) { - interval = PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE); + // code can handle. (Note: we already forced |interval| to be non-negative, + // so the PRUint32 cast (to avoid compiler warnings) is ok.) + PRUint32 maxTimeoutMs = PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE); + if (static_cast(interval) > maxTimeoutMs) { + interval = maxTimeoutMs; } nsTimeout *timeout = new nsTimeout(); - if (!timeout) - return NS_ERROR_OUT_OF_MEMORY; // Increment the timeout's reference count to represent this function's hold // on the timeout.