]> Cypherpunks repositories - gostls13.git/commitdiff
plugin: do not leak cRelName on error path
authorDavid Crawshaw <crawshaw@golang.org>
Mon, 31 Oct 2016 12:59:05 +0000 (08:59 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Tue, 1 Nov 2016 16:04:28 +0000 (16:04 +0000)
Fixes #17683

Change-Id: I46f45c63796b58e8a8f14e37592231cbe7cd6934
Reviewed-on: https://go-review.googlesource.com/32438
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/plugin/plugin_dlopen.go

index 4a3eb3d8618fc6de88298535806111be3fb22906..f4addde74ce453107b3c47ee8b812c7ba4d579a5 100644 (file)
@@ -44,10 +44,10 @@ func open(name string) (*Plugin, error) {
        defer C.free(unsafe.Pointer(cPath))
 
        cRelName := C.CString(name)
+       defer C.free(unsafe.Pointer(cRelName))
        if C.realpath(cRelName, cPath) == nil {
                return nil, errors.New("plugin.Open(" + name + "): realpath failed")
        }
-       C.free(unsafe.Pointer(cRelName))
 
        filepath := C.GoString(cPath)