Commit e9ca7876 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[builtins] Handle uintptr overflow in Array.prototype.sort

... and let it gracefully crash with OOM.

Bug: v8:4153, chromium:1018598
Change-Id: I20dd9874cdbdf78665de3a83d0bc1611dc088c68
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1883551Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64589}
parent 48fb778e
......@@ -108,9 +108,16 @@ namespace array {
receiver: JSReceiver, initialReceiverLength: Number): intptr {
// TODO(szuend): Implement full range sorting, not only up to MaxSmi.
// https://crbug.com/v8/7970.
let clampedReceiverLength: uintptr =
Convert<uintptr>(initialReceiverLength);
if (clampedReceiverLength > kSmiMaxValue) {
let clampedReceiverLength: uintptr;
try {
clampedReceiverLength =
ChangeSafeIntegerNumberToUintPtr(initialReceiverLength)
otherwise UIntPtrOverflow;
if (clampedReceiverLength > kSmiMaxValue) {
clampedReceiverLength = kSmiMaxValue;
}
}
label UIntPtrOverflow {
clampedReceiverLength = kSmiMaxValue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment