From be3c62209592511b67e5b78d743102d6315ded8e Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 12 Dec 2024 10:10:28 -0700 Subject: [PATCH] Also avoid allocating zero len slice in ProveNextStep --- validator/server_arb/machine.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index c781234124..e4e07d3c2d 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -306,8 +306,11 @@ func (m *ArbitratorMachine) ProveNextStep() []byte { output := &C.RustBytes{} C.arbitrator_gen_proof(m.ptr, output) + defer C.free_rust_bytes(*output) + if output.len == 0 { + return nil + } proofBytes := C.GoBytes(unsafe.Pointer(output.ptr), C.int(output.len)) - C.free_rust_bytes(*output) return proofBytes }