Commit Graph

1 Commits

Author SHA1 Message Date
Andreas Kling
943319453d LibJS: Fix syntax highlighter position starting at invalid sentinel
The RehighlightState designated initializer used `.position = {}`
which invokes TextPosition's default constructor, initializing line
and column to 0xFFFFFFFF (the "invalid" sentinel). This overrode
the struct's default member initializer of { 0, 0 }.

When advance_position() processed the first newline, it incremented
0xFFFFFFFF to 0x100000000, producing line numbers in the billions.
These bogus positions propagated into folding regions, causing an
out-of-bounds crash in Document::set_folding_regions() when viewing
page source on pages with <script> blocks.

Fix by explicitly initializing position to { 0, 0 }.

Fixes #8529.
2026-03-20 15:32:33 +01:00