Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unsoundness in
new_library_with_data
The `library_data` slice passed to the function that the dispatch data object is referencing does not necessarily outlive the library in which it will be contained. (Note: It _looks_ like we're upholding memory management rules here, as the object returned from `dispatch_data_create` is released with `dispatch_release` before the end of the function, but remember that the dispatch data is a reference-counted object; `MTLLibrary` will retain the dispatch data beyond the lifetime of the function). As specified in https://developer.apple.com/documentation/dispatch/1452970-dispatch_data_create, if we use DISPATCH_DATA_DESTRUCTOR_DEFAULT as the destructor block instead, `dispatch` will copy the buffer for us automatically.
- Loading branch information