SwiftPrivilegedHelper icon indicating copy to clipboard operation
SwiftPrivilegedHelper copied to clipboard

Memory leak when deserializing AuthorizationExternalForm

Open paya-cz opened this issue 5 years ago • 1 comments

I believe you should be calling .deallocate on UnsafeMutablePointer instances, right? With respect to HelperAuthorization.swift file.

Alternatively, use a cleaner code:

var externalForm = AuthorizationExternalForm()
withUnsafeMutableBytes(of: &externalForm) {
    data.copyBytes(to: $0)
    return
}

paya-cz avatar Apr 10 '19 18:04 paya-cz

Thank you for this, you are correct that the unsafe pointers should be deallocated. And your example makes it even better, so thank you for helping me with that.

erikberglund avatar Apr 16 '19 21:04 erikberglund