rustc: Zero out unique pointers after we drop them

This commit is contained in:
Patrick Walton 2011-09-02 17:51:03 -07:00 committed by Tim Chevalier
parent 477c1bf6e1
commit 07691e725a
2 changed files with 7 additions and 1 deletions

View file

@ -1386,7 +1386,12 @@ fn make_drop_glue(bcx: &@block_ctxt, v0: ValueRef, t: ty::t) {
ty::ty_vec(_) { tvec::make_drop_glue(bcx, v0, t) }
ty::ty_istr. { tvec::make_drop_glue(bcx, v0, t) }
ty::ty_box(_) { decr_refcnt_maybe_free(bcx, v0, v0, t) }
ty::ty_uniq(_) { trans_shared_free(bcx, Load(bcx, v0)) }
ty::ty_uniq(_) {
let vptr = Load(bcx, v0);
let bcx = trans_shared_free(bcx, vptr);
Store(bcx, C_null(val_ty(vptr)), v0);
bcx
}
ty::ty_obj(_) {
let box_cell =
GEP(bcx, v0, [C_int(0), C_int(abi::obj_field_box)]);

View file

@ -87,6 +87,7 @@ fn make_drop_glue(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t)
drop_cx = iter_vec(drop_cx, vptrptr, vec_ty, trans::drop_ty);
}
drop_cx = trans::trans_shared_free(drop_cx, vptr);
Store(drop_cx, C_null(val_ty(vptr)), vptrptr);
Br(drop_cx, next_cx.llbb);
ret next_cx;
}