crypto/x509: potential memory leak on macOS #51752
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
OS-Darwin
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Not sure.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I’m writing bindings for a subset of macOS framework APIs, and while looking up Core Foundation examples, I’ve noticed suspicious CFMutableArray usage in Go.
On macOS, crypto/x509 uses Core Foundation types to interact with Security framework. In particular, it uses CFArrayCreateMutable with CFArrayCallBacks set to zero (i.e. NULL). Apple docs state that a NULL value is identical to release/retain callbacks set to NULL.
go/src/crypto/x509/internal/macos/corefoundation.go
Lines 158 to 161 in d17b65f
CFArrayCreateMutable is used in
(*x509.Certificate).systemVerify
, where a leaf certificate allocated withSecCertificateCreateWithData
is appended and never released explicitly.go/src/crypto/x509/root_darwin.go
Lines 13 to 16 in d17b65f
What did you expect to see?
kCFTypeArrayCallBacks argument and CFRelease call.
What did you see instead?
I’d assume that the memory is never released, but I haven’t tested this yet.
The text was updated successfully, but these errors were encountered: