Skip to content

Commit

Permalink
Fix code scanning alert no. 1: Incorrect conversion between integer t…
Browse files Browse the repository at this point in the history
…ypes

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 949a1e0 commit 33d80ea
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package jobs
import (
"encoding/json"
"strconv"
"math"
"unsafe"
)

Expand Down Expand Up @@ -90,12 +91,17 @@ func (p Pipeline) Int(name string, d int) int {
switch v := value.(type) {
// the most probable case
case string:
res, err := strconv.ParseInt(v, 10, 64)
res, err := strconv.ParseInt(v, 10, 32)
if err != nil {
// return default on failure
return d
}

if res > math.MaxInt32 || res < math.MinInt32 {
// return default if out of bounds
return d
}

return int(res)
case int:
return v
Expand Down

0 comments on commit 33d80ea

Please sign in to comment.