diff --git a/cmd/generate-bindings/solana/anchor-go/generator/unmarshal.go b/cmd/generate-bindings/solana/anchor-go/generator/unmarshal.go index 035acf85..a0f45fb1 100644 --- a/cmd/generate-bindings/solana/anchor-go/generator/unmarshal.go +++ b/cmd/generate-bindings/solana/anchor-go/generator/unmarshal.go @@ -300,6 +300,18 @@ func (g *Generator) gen_unmarshal_DefinedFieldsNamed( ), ), ) + argBody.If(Id("vecLen").Op(">").Id("decoder").Dot("Remaining").Call()).Block( + Return( + Qual(PkgAnchorGoErrors, "NewField").Call( + Lit(exportedArgName), + Qual("fmt", "Errorf").Call( + Lit("vector length %d exceeds remaining decoder bytes %d"), + Id("vecLen"), + Id("decoder").Dot("Remaining").Call(), + ), + ), + ), + ) // Create the vector: argBody.Id("obj").Dot(goFieldName).Op("=").Make(Index().Id(enumTypeName), Id("vecLen")) // Read the vector items: