Skip to content

Commit

Permalink
Free config string in emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
erokhinav committed Aug 28, 2024
1 parent 66ea158 commit 6f6de06
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tvm/tvmExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ func SetVerbosityLevel(level int) error {
}

func CreateConfig(configRaw string) (*Config, error) {
config := C.emulator_config_create(C.CString(configRaw))
configStr := C.CString(configRaw)
defer C.free(unsafe.Pointer(configStr))

config := C.emulator_config_create(configStr)
if config == nil {
return nil, fmt.Errorf("failed to create config")
}
Expand Down Expand Up @@ -257,10 +260,10 @@ func (e *Emulator) setC7(address string, unixTime uint32) error {
return err
}
cConfigStr := C.CString(e.config)
defer C.free(unsafe.Pointer(cConfigStr))
if e.config == "" {
cConfigStr = nil
}
defer C.free(unsafe.Pointer(cConfigStr))
cAddressStr := C.CString(address)
defer C.free(unsafe.Pointer(cAddressStr))
cSeedStr := C.CString(hex.EncodeToString(seed[:]))
Expand Down

0 comments on commit 6f6de06

Please sign in to comment.