Skip to content

Freeze template objects read from bytecode - #1889

Open
trackoor wants to merge 1 commit into
quickjs-ng:masterfrom
trackoor:fix-bytecode-template-not-frozen
Open

trackoor wants to merge 1 commit into
quickjs-ng:masterfrom
trackoor:fix-bytecode-template-not-frozen

Conversation

@trackoor

@trackoor trackoor commented Nov 4, 2026

Copy link
Copy Markdown

The parser seals template objects with seal_template_obj(): the
elements are non-writable and non-configurable, length is made
read-only and the object non-extensible. JS_WriteArray() stores them as
BC_TAG_TEMPLATE_OBJECT, but JS_ReadArray() only called
JS_PreventExtensions(), so length stayed writable and
Object.isFrozen() of a tagged template's strings (and of its raw
array) was false in code loaded from bytecode (qjs -c, qjsc, bjson),
although GetTemplateObject freezes both.

Use seal_template_obj() when reading them too.

Fixes #1888

The parser seals template objects with seal_template_obj(): the
elements are non-writable and non-configurable, `length` is made
read-only and the object non-extensible. JS_WriteArray() stores them as
BC_TAG_TEMPLATE_OBJECT, but JS_ReadArray() only called
JS_PreventExtensions(), so `length` stayed writable and
Object.isFrozen() of a tagged template's strings (and of its `raw`
array) was false in code loaded from bytecode (qjs -c, qjsc, bjson),
although GetTemplateObject freezes both.

Use seal_template_obj() when reading them too.

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.

Template objects read back from bytecode are not frozen (length stays writable)

1 participant