Skip to content

Commit c44c7c5

Browse files
committed
rustc: Zero out slots after dropping them
1 parent 56e040e commit c44c7c5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
768768
type val_and_ty_fn =
769769
fn(@block_ctxt cx, ValueRef v, @typeck.ty t) -> result;
770770

771-
// Iterates through the elements of a tup, rec or tag.
771+
// Iterates through the elements of a box, tup, rec or tag.
772772
fn iter_structural_ty(@block_ctxt cx,
773773
ValueRef v,
774774
@typeck.ty t,
@@ -968,7 +968,13 @@ fn incr_all_refcnts(@block_ctxt cx,
968968
fn drop_slot(@block_ctxt cx,
969969
ValueRef slot,
970970
@typeck.ty t) -> result {
971-
be drop_ty(cx, load_non_structural(cx, slot, t), t);
971+
auto llptr = load_non_structural(cx, slot, t);
972+
auto re = drop_ty(cx, llptr, t);
973+
974+
auto llty = val_ty(slot);
975+
auto llelemty = lib.llvm.llvm.LLVMGetElementType(llty);
976+
re.bcx.build.Store(C_null(llelemty), slot);
977+
ret re;
972978
}
973979

974980
fn drop_ty(@block_ctxt cx,

0 commit comments

Comments
 (0)