From 053ce0184c586b27a054c51e5b24132778156d14 Mon Sep 17 00:00:00 2001 From: pg9182 <96569817+pg9182@users.noreply.github.com> Date: Thu, 13 Oct 2022 01:44:38 -0400 Subject: pkg/{pdata,pdef/pdefgen}: Fix string length check --- pkg/pdata/persistent_player_data_version_231.go | 2 +- pkg/pdef/pdefgen/pdefgen.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'pkg') diff --git a/pkg/pdata/persistent_player_data_version_231.go b/pkg/pdata/persistent_player_data_version_231.go index 6e5d835..cd1898a 100644 --- a/pkg/pdata/persistent_player_data_version_231.go +++ b/pkg/pdata/persistent_player_data_version_231.go @@ -64,7 +64,7 @@ func must(err error) { } func putString(b []byte, x string) error { s := []byte(x) - if len(s) > len(s) { + if len(s) > len(b) { return fmt.Errorf("string length %d too long for field length %d", len(s), len(b)) } for i, c := range s { diff --git a/pkg/pdef/pdefgen/pdefgen.go b/pkg/pdef/pdefgen/pdefgen.go index 80256fd..49aa19c 100644 --- a/pkg/pdef/pdefgen/pdefgen.go +++ b/pkg/pdef/pdefgen/pdefgen.go @@ -129,7 +129,7 @@ func main() { pln(&buf, `func putString(b []byte, x string) error {`) pln(&buf, `s := []byte(x)`) - pln(&buf, `if len(s) > len(s) {`) + pln(&buf, `if len(s) > len(b) {`) pln(&buf, `return fmt.Errorf(%#v, len(s), len(b))`, `string length %d too long for field length %d`) pln(&buf, `}`) pln(&buf, `for i, c := range s {`) -- cgit v1.2.3