From 43121a02e7c42bf4ab31110b22907bb5b9919e59 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 4 Jul 2013 15:27:12 +0100 Subject: [PATCH] golang: Don't try to free the result of guestfs_last_error. The return value is a constant string, part of the handle, and it must not be freed by the golang code. --- generator/golang.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/golang.ml b/generator/golang.ml index c21505317..f7010bcc9 100644 --- a/generator/golang.ml +++ b/generator/golang.ml @@ -112,8 +112,8 @@ func (e *GuestfsError) String() string { } func get_error_from_handle (g *Guestfs, op string) *GuestfsError { + // NB: DO NOT try to free c_errmsg! c_errmsg := C.guestfs_last_error (g.g) - defer C.free (unsafe.Pointer (c_errmsg)) errmsg := C.GoString (c_errmsg) errno := syscall.Errno (C.guestfs_last_errno (g.g))