Skip to content

Commit 73b87c0

Browse files
authored
Merge pull request #543 from CosmWasm/co/fix-errorWithMessage
Fix `errorWithMessage`
2 parents caa4c0f + a716026 commit 73b87c0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/api/lib.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,13 @@ func convertGasReport(report C.GasReport) types.GasReport {
796796
/**** To error module ***/
797797

798798
func errorWithMessage(err error, b C.UnmanagedVector) error {
799+
// we always destroy the unmanaged vector to avoid a memory leak
800+
msg := copyAndDestroyUnmanagedVector(b)
801+
799802
// this checks for out of gas as a special case
800803
if errno, ok := err.(syscall.Errno); ok && int(errno) == 2 {
801804
return types.OutOfGasError{}
802805
}
803-
msg := copyAndDestroyUnmanagedVector(b)
804806
if msg == nil {
805807
return err
806808
}

0 commit comments

Comments
 (0)