Skip to content

Commit 75ee43e

Browse files
authored
Merge pull request #51 from intel/alert-autofix-18
Potential fix for code scanning alert no. 18: Incorrect conversion between integer types
2 parents bb3d582 + 5ead7ee commit 75ee43e

File tree

1 file changed

+6
-1
lines changed
  • src/gprofiler_flamedb_rest/common

1 file changed

+6
-1
lines changed

src/gprofiler_flamedb_rest/common/misc.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"io"
2424
"os"
2525
"strconv"
26+
"math"
2627
"strings"
2728
"time"
2829

@@ -52,7 +53,11 @@ func LookupEnvOrDefault[V lookupEnvConstraint](key string, defaultValue V) V {
5253
ret = val
5354
case int:
5455
i, _ := strconv.ParseInt(val, 10, 64)
55-
ret = int(i)
56+
if i >= math.MinInt && i <= math.MaxInt {
57+
ret = int(i)
58+
} else {
59+
ret = defaultValue
60+
}
5661
case bool:
5762
ret = !(strings.EqualFold(val, "false") || strings.EqualFold(val, "0"))
5863
}

0 commit comments

Comments
 (0)