Alex Crichton 2ff2e2505a Fix use-after-free with closures in JS bindings
This commit fixes an erroneous use-after-free which can happen in
erroneous situations in JS. It's intended that if you invoke a closure
after its environment has been destroyed that you'll immediately get an
error from Rust saying so. The JS binding generation for mutable
closures, however, accidentally did not protect against this.

Each closure has an internal reference count which is incremented while
being invoked and decremented when the invocation finishes and also when
the `Closure` in Rust is dropped. That means there's two branches where
the reference count reaches zero and the internal pointer stored in JS
needs to be set to zero. Only one, however, actually set the pointer to
zero!

This means that if a closure was destroyed while it was being invoked it
would not correctly set its internal pointer to zero. A further
invocation of the closure would then pass as seemingly valid pointer
into Rust, causing a use-after-free.

A test isn't included here specifically for this because our CI has
started failing left-and-right over this test, so this commit will
hopefully just make our CI green!
2019-03-21 15:57:08 -07:00
..
2019-03-13 11:02:27 -07:00
2019-03-21 14:00:33 -07:00
2019-03-13 11:02:27 -07:00
2019-03-13 11:02:27 -07:00
2019-03-13 11:02:27 -07:00
2019-03-13 11:02:27 -07:00
2019-03-13 11:02:27 -07:00
2018-11-27 12:07:59 -08:00
2019-03-15 22:15:04 -03:00
2019-03-13 11:02:27 -07:00
fix
2019-03-14 12:50:50 -06:00
2019-03-13 11:02:27 -07:00