Skip to content

Commit e25e4b1

Browse files
authored
fix: Exclude BLOCK_MAXSIZE and OBJECT_MAXSIZE from bounds checking (#1842)
1 parent ca02a7d commit e25e4b1

File tree

117 files changed

+237
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+237
-237
lines changed

std/assembly/rt/tcms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function initLazy(space: Object): Object {
122122
// @ts-ignore: decorator
123123
@global @unsafe
124124
export function __new(size: usize, id: i32): usize {
125-
if (size >= OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
125+
if (size > OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
126126
var obj = changetype<Object>(__alloc(OBJECT_OVERHEAD + size) - BLOCK_OVERHEAD);
127127
obj.rtId = id;
128128
obj.rtSize = <u32>size;
@@ -140,7 +140,7 @@ export function __renew(oldPtr: usize, size: usize): usize {
140140
memory.copy(newPtr, oldPtr, min(size, oldObj.rtSize));
141141
return newPtr;
142142
}
143-
if (size >= OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
143+
if (size > OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
144144
total -= oldObj.size;
145145
var newPtr = __realloc(oldPtr - OBJECT_OVERHEAD, OBJECT_OVERHEAD + size) + OBJECT_OVERHEAD;
146146
var newObj = changetype<Object>(newPtr - TOTAL_OVERHEAD);

std/assembly/rt/tlsf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ function computeSize(size: usize): usize {
455455

456456
/** Prepares and checks an allocation size. */
457457
function prepareSize(size: usize): usize {
458-
if (size >= BLOCK_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
458+
if (size > BLOCK_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
459459
return computeSize(size);
460460
}
461461

tests/compiler/call-super.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,12 +1244,12 @@
12441244
(local $4 i32)
12451245
local.get $1
12461246
i32.const 1073741820
1247-
i32.ge_u
1247+
i32.gt_u
12481248
if
12491249
i32.const 1104
12501250
i32.const 1440
12511251
i32.const 458
1252-
i32.const 30
1252+
i32.const 29
12531253
call $~lib/builtins/abort
12541254
unreachable
12551255
end

tests/compiler/call-super.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,12 +1590,12 @@
15901590
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
15911591
local.get $0
15921592
i32.const 1073741820
1593-
i32.ge_u
1593+
i32.gt_u
15941594
if
15951595
i32.const 80
15961596
i32.const 416
15971597
i32.const 458
1598-
i32.const 30
1598+
i32.const 29
15991599
call $~lib/builtins/abort
16001600
unreachable
16011601
end

tests/compiler/class-implements.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,12 +1600,12 @@
16001600
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16011601
local.get $0
16021602
i32.const 1073741820
1603-
i32.ge_u
1603+
i32.gt_u
16041604
if
16051605
i32.const 32
16061606
i32.const 368
16071607
i32.const 458
1608-
i32.const 30
1608+
i32.const 29
16091609
call $~lib/builtins/abort
16101610
unreachable
16111611
end

tests/compiler/class-overloading.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,12 +1606,12 @@
16061606
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16071607
local.get $0
16081608
i32.const 1073741820
1609-
i32.ge_u
1609+
i32.gt_u
16101610
if
16111611
i32.const 64
16121612
i32.const 400
16131613
i32.const 458
1614-
i32.const 30
1614+
i32.const 29
16151615
call $~lib/builtins/abort
16161616
unreachable
16171617
end

tests/compiler/class.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,12 +1251,12 @@
12511251
(local $4 i32)
12521252
local.get $1
12531253
i32.const 1073741820
1254-
i32.ge_u
1254+
i32.gt_u
12551255
if
12561256
i32.const 1056
12571257
i32.const 1392
12581258
i32.const 458
1259-
i32.const 30
1259+
i32.const 29
12601260
call $~lib/builtins/abort
12611261
unreachable
12621262
end

tests/compiler/class.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,12 +1702,12 @@
17021702
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
17031703
local.get $0
17041704
i32.const 1073741820
1705-
i32.ge_u
1705+
i32.gt_u
17061706
if
17071707
i32.const 32
17081708
i32.const 368
17091709
i32.const 458
1710-
i32.const 30
1710+
i32.const 29
17111711
call $~lib/builtins/abort
17121712
unreachable
17131713
end

tests/compiler/constructor.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,12 +1312,12 @@
13121312
(local $4 i32)
13131313
local.get $1
13141314
i32.const 1073741820
1315-
i32.ge_u
1315+
i32.gt_u
13161316
if
13171317
i32.const 1056
13181318
i32.const 1392
13191319
i32.const 458
1320-
i32.const 30
1320+
i32.const 29
13211321
call $~lib/builtins/abort
13221322
unreachable
13231323
end

tests/compiler/constructor.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,12 +1600,12 @@
16001600
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16011601
local.get $0
16021602
i32.const 1073741820
1603-
i32.ge_u
1603+
i32.gt_u
16041604
if
16051605
i32.const 32
16061606
i32.const 368
16071607
i32.const 458
1608-
i32.const 30
1608+
i32.const 29
16091609
call $~lib/builtins/abort
16101610
unreachable
16111611
end

0 commit comments

Comments
 (0)