зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1112537 - Showing overflow message instead of OOM message; r=nbp
This commit is contained in:
Родитель
1c93b0554e
Коммит
674f3d59e2
|
@ -7,6 +7,7 @@
|
|||
#include "jsarray.h"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
@ -48,6 +49,7 @@ using namespace js::types;
|
|||
using mozilla::Abs;
|
||||
using mozilla::ArrayLength;
|
||||
using mozilla::CeilingLog2;
|
||||
using mozilla::CheckedInt;
|
||||
using mozilla::DebugOnly;
|
||||
using mozilla::IsNaN;
|
||||
|
||||
|
@ -1072,7 +1074,13 @@ js::ArrayJoin(JSContext *cx, HandleObject obj, HandleLinearString sepstr, uint32
|
|||
// The separator will be added |length - 1| times, reserve space for that
|
||||
// so that we don't have to unnecessarily grow the buffer.
|
||||
size_t seplen = sepstr->length();
|
||||
if (length > 0 && !sb.reserve(seplen * (length - 1)))
|
||||
CheckedInt<uint32_t> res = CheckedInt<uint32_t>(seplen) * (length - 1);
|
||||
if (length > 0 && !res.isValid()) {
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (length > 0 && !sb.reserve(res.value()))
|
||||
return nullptr;
|
||||
|
||||
// Various optimized versions of steps 7-10.
|
||||
|
|
Загрузка…
Ссылка в новой задаче