Skip to content

Commit dbf8c24

Browse files
st0012ko1
authored andcommitted
Avoid passing nil path to File.basename
Some frames may not aways have `path` value. ``` irb((run)@bin/rails:in `require' (not under control)):003:0> frame.location => "bin/rails:in `require'" irb((run)@bin/rails:in `require' (not under control)):004:0> frame.path => nil ``` And when that happens, `File.basename(nil)` would cause exception and crash the debugger.
1 parent 91985af commit dbf8c24

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/debug/server_dap.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ def process_dap args
610610
event! :dap_result, :backtrace, req, {
611611
stackFrames: @target_frames.map{|frame|
612612
path = frame.realpath || frame.path
613+
source_name = path ? File.basename(path) : frame.location.to_s
614+
613615
if !UI_DAP.local_fs || !(path && File.exist?(path))
614616
ref = frame.file_lines
615617
end
@@ -620,7 +622,7 @@ def process_dap args
620622
line: frame.location.lineno,
621623
column: 1,
622624
source: {
623-
name: File.basename(frame.path),
625+
name: source_name,
624626
path: path,
625627
sourceReference: ref,
626628
},

0 commit comments

Comments
 (0)