Skip to content

Commit 3405c54

Browse files
author
Elliott Slaughter
committed
gc: Avoid freeing null pointers.
1 parent 9ea4afe commit 3405c54

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libcore/gc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ unsafe fn walk_gc_roots(mem: Memory, visitor: Visitor) {
102102
match sp {
103103
Some(sp_info) => {
104104
for walk_safe_point(frame.fp, sp_info) |root, tydesc| {
105+
// Skip null pointers, which can occur when a
106+
// unique pointer has already been freed.
107+
if ptr::is_null(*root) {
108+
again;
109+
}
110+
105111
if ptr::is_null(tydesc) {
106112
// Root is a generic box.
107113
let refcount = **root;

0 commit comments

Comments
 (0)