rustls / rustls-ffi

Use Rustls from any language
Other
125 stars 30 forks source link

Fix freeing of Arcs #283

Closed jsha closed 1 year ago

jsha commented 1 year ago

Miri detected UB in how we were freeing Arcs. We were first creating a reference from the passed-in pointer, then passing that reference as input to Arc::from_raw, which by implicit conversion turned it back into a *const Foo.

Not only was this unnecessary, it is UB according to Stacked Borrows: the reference created a SharedReadOnly tag on the stack; but dropping the Arc requires SharedReadWrite because it decrements the ref count.