-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Describe the bug
I believe that this method:
egui/crates/egui-winit/src/clipboard.rs
Line 32 in 8b8595b
| pub fn new(_raw_display_handle: Option<RawDisplayHandle>) -> Self { |
It calls this method from smithay-clipboard (with the smithay-clipboard feature on): https://github.com/Smithay/smithay-clipboard/blob/26c2f53f15f6bdc4f41a442d0ae2c2d63bbc617c/src/lib.rs#L34, however, the safety requirements of that method cannot be guaranteed to be upheld by egui-winit.
/// # Safety
///
/// `display` must be a valid `*mut wl_display` pointer, and it must remain
/// valid for as long as `Clipboard` object is alive.
pub unsafe fn new(display: *mut c_void) -> Self { ... }To Reproduce
I believe that this is enough of an issue in theory, but here is a minimal demonstration of the safety hazard with 100% safe code: https://github.com/SuchAFuriousDeath/smithay-clipboard-segfault. The code in the repo segfaults when dropping the Clipboard.
Expected behavior
I believe the method should be unsafe and pass the safety requirement onto the caller just like the smithay-clipboard method does.
Additional context
I believe this might be the cause of #7660, but I consider this distant enough to warrant a separate issue.