fix fuzz result

i returned which is how i normally code but returning doesnt set stuff which made things break here

[]byte("80\x00\x01\x05\x01\x010\x01\x00")
This commit is contained in:
adman
2025-12-25 17:57:59 +01:00
parent b2f882a9ea
commit 6369ed08e2
2 changed files with 13 additions and 6 deletions
+5 -6
View File
@@ -477,7 +477,6 @@ func RegistryEntryHolderDecoder(g *Generator, varToSet ast.Expr, dataRaw any, na
if err != nil { if err != nil {
return return
} }
idPath := If(NotEquals(Ident(idName), NumLit(0)), NewBlockEllipsis(Assign121(varToSet, Ident(idName)), Return()))
otherwiseType, err := g.VisitType(data.Otherwise.Type) otherwiseType, err := g.VisitType(data.Otherwise.Type)
if err != nil { if err != nil {
@@ -485,20 +484,20 @@ func RegistryEntryHolderDecoder(g *Generator, varToSet ast.Expr, dataRaw any, na
} }
resName := name + "Result" resName := name + "Result"
resNameIdent := Ident(resName) resNameIdent := Ident(resName)
resultVar := VarStmt(resName, otherwiseType) var otherwisePath []ast.Stmt
otherwisePath = append(otherwisePath, VarStmt(resName, otherwiseType))
otherwiseDecodeStatements, err := g.VisitDecoder(resNameIdent, data.Otherwise.Type, name+"Otherwise") otherwiseDecodeStatements, err := g.VisitDecoder(resNameIdent, data.Otherwise.Type, name+"Otherwise")
if err != nil { if err != nil {
return return
} }
resultAssign := Assign121(varToSet, resNameIdent) otherwisePath = append(otherwisePath, otherwiseDecodeStatements...)
otherwisePath = append(otherwisePath, Assign121(varToSet, resNameIdent))
idPath := IfElse(NotEquals(Ident(idName), NumLit(0)), NewBlockEllipsis(Assign121(varToSet, Ident(idName))), NewBlock(otherwisePath))
s = append(s, IdVar) s = append(s, IdVar)
s = append(s, idDecodeStatements...) s = append(s, idDecodeStatements...)
s = append(s, idPath) s = append(s, idPath)
s = append(s, resultVar)
s = append(s, otherwiseDecodeStatements...)
s = append(s, resultAssign)
return return
} }
+8
View File
@@ -196,6 +196,14 @@ func If(cond ast.Expr, body *ast.BlockStmt) *ast.IfStmt {
} }
} }
func IfElse(cond ast.Expr, body *ast.BlockStmt, els *ast.BlockStmt) *ast.IfStmt {
return &ast.IfStmt{
Cond: cond,
Body: body,
Else: els,
}
}
func NotEquals(lhs, rhs ast.Expr) *ast.BinaryExpr { func NotEquals(lhs, rhs ast.Expr) *ast.BinaryExpr {
return &ast.BinaryExpr{ return &ast.BinaryExpr{
X: lhs, X: lhs,