Skip to content

Commit 6c817cf

Browse files
committed
Ensure drops don't close unrelated objects
1 parent 16895b3 commit 6c817cf

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/hl/file.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ pub mod tests {
516516
assert!(crate::handle::refcount(fileid).is_err());
517517
assert!(crate::handle::refcount(groupid).is_err());
518518
assert!(!group.is_valid());
519+
drop(group);
519520
});
520521
});
521522
}

src/hl/group.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ pub mod tests {
269269
h5lock!({
270270
file.close().unwrap();
271271
assert_eq!(format!("{:?}", a), "<HDF5 group: invalid id>");
272+
drop(a);
273+
drop(ab);
274+
drop(abc);
272275
})
273276
})
274277
}

src/hl/object.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ pub mod tests {
124124
obj.decref();
125125
assert_eq!(obj.refcount(), 1);
126126
obj.decref();
127-
obj.decref();
128-
assert_eq!(obj.refcount(), 0);
129-
assert!(!obj.is_valid());
130-
assert!(!is_valid_user_id(obj.id()));
131-
assert!(!is_valid_id(obj.id()));
127+
h5lock!({
128+
obj.decref();
129+
assert_eq!(obj.refcount(), 0);
130+
assert!(!obj.is_valid());
131+
assert!(!is_valid_user_id(obj.id()));
132+
assert!(!is_valid_id(obj.id()));
133+
drop(obj);
134+
});
132135
}
133136

134137
#[test]
@@ -166,6 +169,8 @@ pub mod tests {
166169
obj.decref();
167170
assert!(!obj.is_valid());
168171
assert!(!obj2.is_valid());
172+
drop(obj);
173+
drop(obj2);
169174
});
170175
}
171176
}

0 commit comments

Comments
 (0)