Skip to content

Commit

Permalink
Fix invalid pointer deref in Weak::as_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed Jun 30, 2020
1 parent fc3dc72 commit 0aecf3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Expand Up @@ -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))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Expand Up @@ -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))
}
}
Expand Down

0 comments on commit 0aecf3c

Please sign in to comment.