Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
protect against bad script IDs; fixes microsoft/vscode#27769
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed Jun 1, 2017
1 parent 0b23634 commit cd97fa6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/node/nodeDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,12 @@ export class NodeDebugSession extends LoggingDebugSession {
}

if (!name) {

if (typeof script_val.id !== 'number') {
// if the script has not ID something is seriously wrong: give up.
throw new Error('no script id');
}

// if a function is dynamically created from a string, its script has no name.
path = this._scriptToPath(script_val);
name = Path.basename(path);
Expand All @@ -2247,11 +2253,6 @@ export class NodeDebugSession extends LoggingDebugSession {

return this._createStackFrameFromSource(frame, src, line, column);

}).catch(err => {

const func_name = this._getFrameName(frame);
const name = localize('frame.error', "{0} <error: {1}>", func_name, err.message);
return new StackFrame(this._frameHandles.create(frame), name);
});
}

Expand Down

0 comments on commit cd97fa6

Please sign in to comment.