Skip to content

Commit

Permalink
check memory leaks implicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Feb 20, 2025
1 parent eec9ccf commit df0a50a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
10 changes: 10 additions & 0 deletions asan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build asan && !cmd_go_bootstrap

package openssl

// -fsanitize=leak instructs the compiler and linker to use the leak sanitizer
// and report memory leaks on exit.

// #cgo CFLAGS: -fsanitize=leak
// #cgo LDFLAGS: -fsanitize=leak
import "C"
4 changes: 0 additions & 4 deletions openssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@ func bnToBinPad(bn C.GO_BIGNUM_PTR, to []byte) error {
return nil
}

func CheckLeaks() {
C.go_openssl_do_leak_check()
}

// versionAtOrAbove returns true when
// (vMajor, vMinor, vPatch) >= (major, minor, patch),
// compared lexicographically.
Expand Down
1 change: 0 additions & 1 deletion openssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func TestMain(m *testing.M) {
// Sleep a bit to let the finalizers run.
time.Sleep(10 * time.Millisecond)
}
openssl.CheckLeaks()
os.Exit(status)
}

Expand Down

0 comments on commit df0a50a

Please sign in to comment.