Skip to content

fix memory leak #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion certificates/install_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import "C"
import (
"errors"
"os/exec"
"unsafe"

log "github.com/sirupsen/logrus"

Expand All @@ -76,7 +77,9 @@ import (
// if something goes wrong will show a dialog with the error and return an error
func InstallCertificate(cert *paths.Path) error {
log.Infof("Installing certificate: %s", cert)
p := C.installCert(C.CString(cert.String()))
ccert := C.CString(cert.String())
defer C.free(unsafe.Pointer(ccert))
p := C.installCert(ccert)
s := C.GoString(p)
if len(s) != 0 {
oscmd := exec.Command("osascript", "-e", "display dialog \""+s+"\" buttons \"OK\" with title \"Error installing certificates\"")
Expand Down
5 changes: 4 additions & 1 deletion systray/exec_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import "C"
import (
"os/exec"
"path/filepath"
"unsafe"

"github.com/sirupsen/logrus"
)
Expand All @@ -67,7 +68,9 @@ func execApp(path string, args ...string) error {
C.setCharArray(argv, C.int(i), C.CString(arg))
}

C.runApplication(C.CString(path), argv, argc)
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
C.runApplication(cpath, argv, argc)

C.freeCharArray(argv, argc)
return nil
Expand Down