Skip to content

Commit 9ec226d

Browse files
LiaoPengdcodeIO
authored andcommitted
Fix possible use after free in Array#forEach if the array resizes halfway (AssemblyScript#408)
1 parent 20f4092 commit 9ec226d

File tree

4 files changed

+871
-529
lines changed

4 files changed

+871
-529
lines changed

std/assembly/array.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ export class Array<T> {
250250
}
251251

252252
forEach(callbackfn: (value: T, index: i32, array: Array<T>) => void): void {
253-
var buffer = this.buffer_;
254253
for (let index = 0, toIndex = this.length_; index < toIndex && index < this.length_; ++index) {
255-
callbackfn(LOAD<T>(buffer, index), index, this);
254+
callbackfn(LOAD<T>(this.buffer_, index), index, this);
256255
}
257256
}
258257

0 commit comments

Comments
 (0)