Skip to content

Commit 0c85f70

Browse files
committed
Fix panic in calcualateMax for empty CPU samples array
1 parent f1e426a commit 0c85f70

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/input/exec.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ func ExecuteCommand(command ResolvedCommand) (ExecutionResult, error) {
244244
}
245245

246246
func calcualateMax(samples []uint64) uint64 {
247+
if len(samples) == 0 {
248+
return 0 // Return 0 for missing CPU data
249+
}
247250
max := samples[0]
248251
for _, sample := range samples {
249252
if sample > max {

0 commit comments

Comments
 (0)