From 26663d45a4bc9b763e01385bdaa2c5801b488573 Mon Sep 17 00:00:00 2001 From: grantseltzer Date: Thu, 12 Dec 2024 08:53:52 -0600 Subject: [PATCH] Nil check for stack traces Signed-off-by: grantseltzer --- pkg/dynamicinstrumentation/uploader/stack_trace.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/dynamicinstrumentation/uploader/stack_trace.go b/pkg/dynamicinstrumentation/uploader/stack_trace.go index f428e2c40e0d24..a0ca4101cba2db 100644 --- a/pkg/dynamicinstrumentation/uploader/stack_trace.go +++ b/pkg/dynamicinstrumentation/uploader/stack_trace.go @@ -114,6 +114,9 @@ func pcToLine(procInfo *ditypes.ProcessInfo, pc uint64) (*funcInfo, error) { return nil, fmt.Errorf("invalid file number in dwarf function entry associated with compile unit") } + if int(fileNumber) >= len(files) || files[fileNumber] == nil { + return nil, fmt.Errorf("could not find file") + } file = files[fileNumber].Name return &funcInfo{