Skip to content

Commit 40e86d1

Browse files
committed
Fix CodeQL allocation overflow alert in column list
Guard the slice capacity computation to satisfy CodeQL's size-overflow analysis.
1 parent 1c23528 commit 40e86d1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/commands/column.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ var columnListCmd = &cobra.Command{
4545
return nil
4646
}
4747

48-
cols := make([]any, 0, 3+len(dataSlice)) //nolint:gosec // len returns non-negative int; +3 cannot overflow
48+
n := len(dataSlice)
49+
if n > (1<<31 - 4) {
50+
n = 0
51+
}
52+
cols := make([]any, 0, 3+n)
4953
cols = append(cols, pseudoColumnObject(pseudoColumnNotNow), pseudoColumnObject(pseudoColumnMaybe))
5054
cols = append(cols, dataSlice...)
5155
cols = append(cols, pseudoColumnObject(pseudoColumnDone))

0 commit comments

Comments
 (0)