Skip to content

Commit

Permalink
Prevent panic: unexpected constant value: <nil> (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly authored Sep 20, 2024
1 parent 6741874 commit 1d23143
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion analyzers/conversion_overflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ func updateResultFromBinOp(result *rangeResult, binOp *ssa.BinOp, instr *ssa.Con
if !ok {
return
}

// TODO: constVal.Value nil check avoids #1229 panic but seems to be hiding a bug in the code above or in x/tools/go/ssa.
if constVal.Value == nil {
// log.Fatalf("[gosec] constVal.Value is nil flipped=%t, constVal=%#v, binOp=%#v", operandsFlipped, constVal, binOp)
return
}
switch binOp.Op {
case token.LEQ, token.LSS:
updateMinMaxForLessOrEqual(result, constVal, binOp.Op, operandsFlipped, successPathConvert)
Expand Down

0 comments on commit 1d23143

Please sign in to comment.