Fix minor memleak in Go bindings (#241)

* Fix minor memleak in Go bindings

* Move fclose back to after nil check

* Move it to correct spot, ugh
This commit is contained in:
Justin Traglia 2023-03-24 08:50:15 -05:00 committed by GitHub
parent 9a93c75e23
commit c448e9bfcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -91,7 +91,11 @@ func LoadTrustedSetupFile(trustedSetupFile string) CKZGRet {
if loaded { if loaded {
panic("trusted setup is already loaded") panic("trusted setup is already loaded")
} }
fp := C.fopen(C.CString(trustedSetupFile), C.CString("rb")) cTrustedSetupFile := C.CString(trustedSetupFile)
defer C.free(unsafe.Pointer(cTrustedSetupFile))
cMode := C.CString("r")
defer C.free(unsafe.Pointer(cMode))
fp := C.fopen(cTrustedSetupFile, cMode)
if fp == nil { if fp == nil {
panic("error reading trusted setup") panic("error reading trusted setup")
} }