提交 07691e72 编写于 作者: P Patrick Walton 提交者: Tim Chevalier

rustc: Zero out unique pointers after we drop them

上级 477c1bf6
......@@ -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)]);
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册