Skip to content

Commit

Permalink
Also avoid allocating zero len slice in ProveNextStep
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Dec 12, 2024
1 parent 155fa7d commit be3c622
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion validator/server_arb/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit be3c622

Please sign in to comment.