erikberglund / SwiftPrivilegedHelper

Example application using a privileged helper tool with authentication in an unsandboxed application written in Swift
MIT License
180 stars 33 forks source link

Memory leak when deserializing AuthorizationExternalForm #13

Open paya-cz opened 5 years ago

paya-cz commented 5 years ago

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
}
erikberglund commented 5 years ago

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.