Skip to content

(#1055): Fix unsoundness in the use of the selectors crate

selector::OpaqueElememt::new() takes a &T, but internally it just casts &T into &() and doesn't care. This is letting unsoundness through the borrow checker.

  impl OpaqueElement {
      /// Creates a new OpaqueElement from an arbitrarily-typed pointer.
      pub fn new<T>(ptr: &T) -> Self {
          unsafe {
              OpaqueElement(NonNull::new_unchecked(
                  ptr as *const T as *const () as *mut (),
              ))
          }
      }
  }

So, we now pass an &Element instead of &Ref<...>, as the latter is ephemeral, as it comes from &node.borrow().

Fixes #1055 (closed)

Edited by Federico Mena Quintero

Merge request reports