Skip to content

Commit 6f6de06

Browse files
committed
Free config string in emulator
1 parent 66ea158 commit 6f6de06

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tvm/tvmExecutor.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ func SetVerbosityLevel(level int) error {
199199
}
200200

201201
func CreateConfig(configRaw string) (*Config, error) {
202-
config := C.emulator_config_create(C.CString(configRaw))
202+
configStr := C.CString(configRaw)
203+
defer C.free(unsafe.Pointer(configStr))
204+
205+
config := C.emulator_config_create(configStr)
203206
if config == nil {
204207
return nil, fmt.Errorf("failed to create config")
205208
}
@@ -257,10 +260,10 @@ func (e *Emulator) setC7(address string, unixTime uint32) error {
257260
return err
258261
}
259262
cConfigStr := C.CString(e.config)
263+
defer C.free(unsafe.Pointer(cConfigStr))
260264
if e.config == "" {
261265
cConfigStr = nil
262266
}
263-
defer C.free(unsafe.Pointer(cConfigStr))
264267
cAddressStr := C.CString(address)
265268
defer C.free(unsafe.Pointer(cAddressStr))
266269
cSeedStr := C.CString(hex.EncodeToString(seed[:]))

0 commit comments

Comments
 (0)