Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Jun 26, 2024
1 parent caa4c0f commit a716026
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/api/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,13 @@ func convertGasReport(report C.GasReport) types.GasReport {
/**** To error module ***/

func errorWithMessage(err error, b C.UnmanagedVector) error {
// we always destroy the unmanaged vector to avoid a memory leak
msg := copyAndDestroyUnmanagedVector(b)

// this checks for out of gas as a special case
if errno, ok := err.(syscall.Errno); ok && int(errno) == 2 {
return types.OutOfGasError{}
}
msg := copyAndDestroyUnmanagedVector(b)
if msg == nil {
return err
}
Expand Down

0 comments on commit a716026

Please sign in to comment.