Skip to content

Object.freeze of a detached fixed-length typed array - #1824

Open
mvanhorn wants to merge 1 commit into
quickjs-ng:masterfrom
mvanhorn:fix/1765-object-freeze-detached-typed-array
Open

mvanhorn wants to merge 1 commit into
quickjs-ng:masterfrom
mvanhorn:fix/1765-object-freeze-detached-typed-array

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

The freeze guard now throws only when array_buffer_is_resizable is true, and a detached fixed-length view continues through the normal freeze path and is returned. Views of resizable buffers are still rejected with the same TypeError. Object.freeze throws TypeError: cannot freeze resizable typed array on a fixed-length typed array after its ArrayBuffer is detached, for example by transfer(). The view has no indexed elements and its buffer is not resizable, so freeze should return the same object.

Tests for this live in tests/bug1765.js.

Fixes #1765

The freeze guard now throws only when array_buffer_is_resizable is true,
and a detached fixed-length view continues through the normal freeze
path and is returned. Views of resizable buffers are still rejected with
the same TypeError. tests/bug1765.js covers freeze of detached
Float32Array and Uint8Array views, freezing a named own property after
detach, the existing invalid descriptor flags failure for an in-bounds
view, length-tracking and fixed-length views of resizable buffers,
Object.seal on a detached view, and freeze of an ordinary object.

Fixes quickjs-ng#1765

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object.freeze throws for a typed array whose buffer is detached

1 participant