From f679cf4d7f60631088535169c2ec877bbdee991b Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Mon, 14 Nov 2022 13:11:14 +0000 Subject: [PATCH] Fix CodeQL warning. --- go.sum | 2 ++ internal/zencmd/window_darwin.go | 3 ++- internal/zencmd/window_unix.go | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index 31590b0..0b17048 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/internal/zencmd/window_darwin.go b/internal/zencmd/window_darwin.go index 70ab603..2a5e5e0 100644 --- a/internal/zencmd/window_darwin.go +++ b/internal/zencmd/window_darwin.go @@ -1,6 +1,7 @@ package zencmd import ( + "math" "strconv" "golang.org/x/sys/unix" @@ -11,7 +12,7 @@ type any = interface{} // ParseWindowId is internal. func ParseWindowId(id string) any { if pid, err := strconv.ParseUint(id, 0, 64); err == nil { - return int(pid) + return int(pid & math.MaxInt) } return id } diff --git a/internal/zencmd/window_unix.go b/internal/zencmd/window_unix.go index c20fe3b..1b98254 100644 --- a/internal/zencmd/window_unix.go +++ b/internal/zencmd/window_unix.go @@ -6,6 +6,7 @@ import ( "bytes" "fmt" "io" + "math" "os/exec" "strconv" "strings" @@ -14,7 +15,7 @@ import ( // ParseWindowId is internal. func ParseWindowId(id string) int { wid, _ := strconv.ParseUint(id, 0, 64) - return int(wid) + return int(wid & math.MaxInt) } // GetParentWindowId is internal.