aboutsummaryrefslogtreecommitdiffstats
path: root/wireguard-go-bridge
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-26 21:11:39 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-26 21:11:39 -0600
commit388e65231590b9aed6c1a952cbb8a03c3c1ad587 (patch)
tree362d96766579720278101a3217eb8d04c1f9d965 /wireguard-go-bridge
parentAdd autorelease pool markers in Go callback functions. (diff)
downloadwireguard-apple-388e65231590b9aed6c1a952cbb8a03c3c1ad587.tar.xz
wireguard-apple-388e65231590b9aed6c1a952cbb8a03c3c1ad587.zip
wireguard-go-bridge: free C strings
Reported-by: Anders Bergh <anders1@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'wireguard-go-bridge')
-rw-r--r--wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go b/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go
index 0caab3e4..77f398ec 100644
--- a/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go
+++ b/wireguard-go-bridge/src/git.zx2c4.com/wireguard-go/api-ios.go
@@ -28,6 +28,7 @@ import (
)
var loggerFunc unsafe.Pointer
+var versionString *C.char
type CLogger struct {
level C.int
@@ -38,13 +39,18 @@ func (l *CLogger) Write(p []byte) (int, error) {
if uintptr(loggerFunc) == 0 {
return 0, errors.New("No logger initialized")
}
- C.callLogger(loggerFunc, l.level, C.CString("WireGuard/GoBackend/"+l.interfaceName), C.CString(string(p)))
+ tag := C.CString("WireGuard/GoBackend/"+l.interfaceName)
+ message := C.CString(string(p))
+ C.callLogger(loggerFunc, l.level, tag, message)
+ C.free(unsafe.Pointer(tag))
+ C.free(unsafe.Pointer(message))
return len(p), nil
}
var tunnelHandles map[int32]*Device
func init() {
+ versionString = C.CString(WireGuardGoVersion)
roamingDisabled = true
tunnelHandles = make(map[int32]*Device)
signals := make(chan os.Signal)
@@ -57,7 +63,9 @@ func init() {
n := runtime.Stack(buf, true)
buf[n] = 0
if uintptr(loggerFunc) != 0 {
- C.callLogger(loggerFunc, 0, C.CString("WireGuard/GoBackend/Stacktrace"), (*_Ctype_char)(unsafe.Pointer(&buf[0])))
+ tag := C.CString("WireGuard/GoBackend/Stacktrace")
+ C.callLogger(loggerFunc, 0, tag, (*_Ctype_char)(unsafe.Pointer(&buf[0])))
+ C.free(unsafe.Pointer(tag))
}
}
}
@@ -122,7 +130,7 @@ func wgTurnOff(tunnelHandle int32) {
//export wgVersion
func wgVersion() *C.char {
- return C.CString(WireGuardGoVersion)
+ return versionString
}
func main() {}