fix: don't recurse into nested index source maps by szuend · Pull Request #25 · ChromeDevTools/source-map-scopes-codec · GitHub
Skip to content

fix: don't recurse into nested index source maps - #25

Merged
szuend merged 1 commit into
mainfrom
fix/no-nested-index-maps
Oct 13, 2026
Merged

szuend merged 1 commit into
mainfrom
fix/no-nested-index-maps

Conversation

@szuend

@szuend szuend commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Per ECMA-426, the "map" of an index source map section is a regular source map; nested index maps are not allowed. The decoder nevertheless recursed into them via decode() <-> decodeIndexMap() without any depth limit, so a deeply nested (~8000 levels, ~0.5 MiB) map overflowed the call stack with a RangeError. Nested maps were also decoded incorrectly, as the inner call reset the outer section's generated offset to 0:0.

decodeIndexMap() now decodes sections with decodeMap() directly and skips sections that are index maps themselves in lax mode, or throws in strict mode.

Per ECMA-426, the "map" of an index source map section is a regular
source map; nested index maps are not allowed. The decoder nevertheless
recursed into them via decode() <-> decodeIndexMap() without any depth
limit, so a deeply nested (~8000 levels, ~0.5 MiB) map overflowed the
call stack with a RangeError. Nested maps were also decoded incorrectly,
as the inner call reset the outer section's generated offset to 0:0.

decodeIndexMap() now decodes sections with decodeMap() directly and
skips sections that are index maps themselves in lax mode, or throws in
strict mode.
@szuend
szuend requested a review from OrKoN October 13, 2026 07:39
@szuend
szuend merged commit 51a6dae into main Oct 13, 2026
7 checks passed
@szuend
szuend deleted the fix/no-nested-index-maps branch October 13, 2026 07:43
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.

2 participants