Skip to content

Commit e6f3f98

Browse files
committed
Add assert(self.offset == 0) in with_mut
1 parent e84f92d commit e6f3f98

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎libcc2rs/src/rc.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ impl<T> Ptr<T> {
429429
match &self.kind {
430430
PtrKind::Null => panic!("ub: null pointer"),
431431
PtrKind::StackSingle(weak) | PtrKind::HeapSingle(weak) => {
432+
assert_eq!(self.offset, 0, "ub: invalid offset");
432433
let rc = weak.upgrade().expect("ub: dangling pointer");
433434
let mut borrow = rc.borrow_mut();
434435
f(&mut *borrow)

0 commit comments

Comments
 (0)