Skip to content

Commit 0aecf3c

Browse files
committed
Fix invalid pointer deref in Weak::as_ptr
1 parent fc3dc72 commit 0aecf3c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/liballoc/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ impl<T> Weak<T> {
17111711
// because dangling weaks are only created for sized T. wrapping_offset
17121712
// is used so that we can use the same code path for dangling weak refs.
17131713
unsafe {
1714-
let offset = data_offset(&raw const (*ptr).value);
1714+
let offset = data_offset(fake_ptr);
17151715
set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset))
17161716
}
17171717
}

src/liballoc/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ impl<T> Weak<T> {
14791479
// because dangling weaks are only created for sized T. wrapping_offset
14801480
// is used so that we can use the same code path for dangling weak refs.
14811481
unsafe {
1482-
let offset = data_offset(&raw const (*ptr).data);
1482+
let offset = data_offset(fake_ptr);
14831483
set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset))
14841484
}
14851485
}

0 commit comments

Comments
 (0)