Skip to content

Commit

Permalink
[fix_memory_leak] Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
risentveber committed Feb 26, 2023
1 parent f5e370d commit f4cb30a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/dll_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

// #cgo CFLAGS: -I${SRCDIR}
// #include <stdlib.h>
// #include "tonclient.h"
//
// void callbackProxy(
Expand All @@ -24,7 +25,9 @@ import (
// tc_string_data_t params_json,
// uint32_t request_id
// ) {
// tc_request(context, name, params_json, request_id, callbackProxy);
// tc_request(context, name, params_json, request_id, callbackProxy);
// free((void*)name.content);
// free((void*)params_json.content);
// }
//
import "C"
Expand Down Expand Up @@ -150,7 +153,9 @@ type contextCreateResponse struct {
}

func (c *dllClientCtx) createContext(data []byte) error {
rawHandler := C.tc_create_context(newTcStr(data))
cStringData := newTcStr(data)
rawHandler := C.tc_create_context(cStringData)
C.free(unsafe.Pointer(cStringData.content))

defer C.tc_destroy_string(rawHandler)
rawResponse := newBytesFromTcStr(C.tc_read_string(rawHandler))
Expand Down

0 comments on commit f4cb30a

Please sign in to comment.