From 14f27ad9ce156de1bba825adcbd9baf0f764390c Mon Sep 17 00:00:00 2001 From: Daniel Podolsky Date: Sat, 21 Nov 2026 22:41:46 +0300 Subject: [PATCH] fix(lexer): make the 32-bit size guard compile on GOARCH=386/arm `math.MaxUint32` (4294967295) does not fit in a 32-bit `int`, so `len(src) > math.MaxUint32` failed to compile on 32-bit targets (e.g. linux/arm7). Compare through uint64 instead; behaviour on 64-bit targets is unchanged because len(src) is always non-negative. Verified: go build ./... and GOOS=linux GOARCH=arm GOARM=7 go build ./...; go test ./lexer/... --- lexer/lexer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lexer/lexer.go b/lexer/lexer.go index 6c7e53a..e61b8f8 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -159,7 +159,7 @@ func matchExponent(b []byte) bool { // and the line start table, following the lexical grammar at // https://protobuf.com/docs/language-spec#lexical-elements. func Lex(src []byte, ts *TokenStream) error { - if len(src) > math.MaxUint32 { + if uint64(len(src)) > math.MaxUint32 { return ErrFileTooLarge }