From 2972599ee3aa5d0a385faf2cbc043aa8a1021aa2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 20 Aug 2018 14:14:55 -0700 Subject: [PATCH] Fix some mistakes from `WeakRef` support * Be sure to free the pointer, not `this.ptr` which is always 0 * Unconditionally attempt to free data and let Rust throw an exception if it's null --- crates/cli-support/src/js/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 4e4b5ca6..357c3837 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -650,11 +650,9 @@ impl<'a> Context<'a> { dst.push_str(&format!( " free() {{ - if (this.ptr === 0) - return; const ptr = this.ptr; this.ptr = 0; - free{}(this.ptr); + free{}(ptr); }} ", name,