Skip to content

fix(consumer): guard sourcesInd against out of range access#23

Open
AruneshDwivedi wants to merge 1 commit into
go-sourcemap:masterfrom
AruneshDwivedi:fix/sourcesind-bounds
Open

fix(consumer): guard sourcesInd against out of range access#23
AruneshDwivedi wants to merge 1 commit into
go-sourcemap:masterfrom
AruneshDwivedi:fix/sourcesind-bounds

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

The source() function indexed m.Sources[match.sourcesInd] only checking sourcesInd >= 0, so a mapping whose decoded sourcesInd equals or exceeds len(m.Sources) (possible from a malformed sourcemap) panicked with index out of range. Bounds-check sourcesInd against the Sources slice length before indexing, matching the existing guard already used by name().

Signed-off-by: Arunesh Dwivedi <arunesh.dwivedi@gmail.com>
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.

1 participant