More CodeQL fixes

This commit is contained in:
Kovid Goyal 2025-04-20 21:53:11 +05:30
parent adfcffa5d7
commit 237bb35ee9
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
6 changed files with 25 additions and 14 deletions

View file

@ -6,6 +6,7 @@ import (
"bytes"
"errors"
"fmt"
"math"
"os"
"os/exec"
"path/filepath"
@ -388,17 +389,18 @@ func (self *handler) switch_mode(mode Mode) {
func (self *handler) handle_hex_key_event(event *loop.KeyEvent) {
text := self.rl.AllText()
val, err := strconv.ParseUint(text, 16, 32)
uval, err := strconv.ParseUint(text, 16, 32)
new_val := -1
if err != nil {
if err != nil || uval > math.MaxInt {
return
}
val := int(uval)
if event.MatchesPressOrRepeat("tab") {
new_val = int(val) + 10
new_val = val + 10
} else if event.MatchesPressOrRepeat("up") {
new_val = int(val) + 1
new_val = val + 1
} else if event.MatchesPressOrRepeat("down") {
new_val = utils.Max(32, int(val)-1)
new_val = max(32, val-1)
}
if new_val > -1 {
event.Handled = true