Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit f976f61

Browse files
dennwcsbinet
authored andcommitted
free allocated strings
1 parent bd44a9e commit f976f61

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

file.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ import "C"
1717

1818
import (
1919
"os"
20+
"unsafe"
2021
)
2122

2223
// FromFile converts a Go file to Python file object.
2324
// Calling close from Python will not close a file descriptor.
2425
func FromFile(f *os.File, mode string) *PyObject {
25-
p := C._gopy_PyFile_FromFile(C.int(f.Fd()), C.CString(f.Name()), C.CString(mode))
26+
cname := C.CString(f.Name())
27+
cmode := C.CString(mode)
28+
p := C._gopy_PyFile_FromFile(C.int(f.Fd()), cname, cmode)
29+
C.free(unsafe.Pointer(cname))
30+
C.free(unsafe.Pointer(cmode))
2631
return togo(p)
2732
}
2833

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy