Skip to content

Commit 370c66a

Browse files
committed
Fix a crash when the segment does not point to a source file
With the following example: ```js var foo = function () { return 4; }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,ewogICJtYXBwaW5ncyI6ICJBQUFBLElBQUEsR0FBQSxHQUFVLFk7U0FBTSxDO0FBQUMsQ0FBakIiLAogICJuYW1lcyI6IFtdLAogICJzb3VyY2VzIjogWyJvcmlnaW5hbC5qcyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsidmFyIGZvbyA9ICgpID0+IDQ7Il0sCiAgInZlcnNpb24iOiAzCn0K ``` Hovering over the `{` or `;` (on line 2) causes a crash. The actually mappings looks like: ``` AAAA,IAAA,GAAA,GAAU,Y;SAAM,C;AAAC,CAAjB ``` Where the `Y` and `C` segments do not have a `sourcesIndex`/`sourceLine`/`sourceColumn` VLQ. This defaults the source `index` variable here to `-1`, which causes the crash.
1 parent 7a479ec commit 370c66a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@
476476
}
477477

478478
// Update the original text area when the source changes
479-
const otherSource = index => sm.sources[index].name;
479+
const otherSource = index => index === -1 ? 'unmapped' : sm.sources[index].name;
480480
const originalName = index => sm.names[index];
481481
originalTextArea = null;
482482
if (sm.sources.length > 0) {

0 commit comments

Comments
 (0)