Fix invalid pointer deref in Weak::as_ptr

This commit is contained in:
CAD97 2020-06-30 12:42:09 -04:00
parent fc3dc723da
commit 0aecf3c74b
2 changed files with 2 additions and 2 deletions

View file

@ -1711,7 +1711,7 @@ impl<T> Weak<T> {
// because dangling weaks are only created for sized T. wrapping_offset
// is used so that we can use the same code path for dangling weak refs.
unsafe {
let offset = data_offset(&raw const (*ptr).value);
let offset = data_offset(fake_ptr);
set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset))
}
}

View file

@ -1479,7 +1479,7 @@ impl<T> Weak<T> {
// because dangling weaks are only created for sized T. wrapping_offset
// is used so that we can use the same code path for dangling weak refs.
unsafe {
let offset = data_offset(&raw const (*ptr).data);
let offset = data_offset(fake_ptr);
set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset))
}
}