Skip to content

Commit

Permalink
Merge pull request #533 from mstoykov/fixNewArrayBuffer
Browse files Browse the repository at this point in the history
Fix using runtime.NewArrayBuffer
  • Loading branch information
dop251 authored Sep 19, 2023
2 parents 9410bca + 07c7e94 commit 865aea3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions builtin_typedarrays.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func (r *Runtime) typedArrayProto_filter(call FunctionCall) Value {
}
}
c := r.speciesConstructorObj(o, ta.defaultCtor)
ab := r._newArrayBuffer(r.global.ArrayBufferPrototype, nil)
ab := r._newArrayBuffer(r.getArrayBufferPrototype(), nil)
ab.data = buf
kept := r.toConstructor(ta.defaultCtor)([]Value{ab.val}, ta.defaultCtor)
if c == ta.defaultCtor {
Expand Down Expand Up @@ -1215,7 +1215,7 @@ func (r *Runtime) typedArray_of(call FunctionCall) Value {
}

func (r *Runtime) allocateTypedArray(newTarget *Object, length int, taCtor typedArrayObjectCtor, proto *Object) *typedArrayObject {
buf := r._newArrayBuffer(r.global.ArrayBufferPrototype, nil)
buf := r._newArrayBuffer(r.getArrayBufferPrototype(), nil)
ta := taCtor(buf, 0, length, r.getPrototypeFromCtor(newTarget, nil, proto))
if length > 0 {
buf.data = allocByteSlice(length * ta.elemSize)
Expand Down
2 changes: 1 addition & 1 deletion typedarrays.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (a ArrayBuffer) Detached() bool {
// using this typed array will result in unaligned access which may cause performance degradation or runtime panics
// on some architectures or configurations.
func (r *Runtime) NewArrayBuffer(data []byte) ArrayBuffer {
buf := r._newArrayBuffer(r.global.ArrayBufferPrototype, nil)
buf := r._newArrayBuffer(r.getArrayBufferPrototype(), nil)
buf.data = data
return ArrayBuffer{
buf: buf,
Expand Down

0 comments on commit 865aea3

Please sign in to comment.