diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-12-12 18:05:37 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-12-24 19:59:52 -0800 |
| commit | 7554f5c58f840b648bc3c5b2d24d0df6683eed03 (patch) | |
| tree | 4f85634f5c5c7eaf974eb2e75d48d4179c5bffc5 /src | |
| parent | 51abdee5f1ad932671350fdd8a7911fe144d08b8 (diff) | |
| download | rust-7554f5c58f840b648bc3c5b2d24d0df6683eed03.tar.gz rust-7554f5c58f840b648bc3c5b2d24d0df6683eed03.zip | |
std: Fix a bug where Local::take() didn't zero out
In the compiled version of local_ptr (that with #[thread_local]), the take() funciton didn't zero-out the previous pointer, allowing for multiple takes (with fewer runtime assertions being tripped).
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/rt/local_ptr.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libstd/rt/local_ptr.rs b/src/libstd/rt/local_ptr.rs index 925aa802ad5..b75f2927003 100644 --- a/src/libstd/rt/local_ptr.rs +++ b/src/libstd/rt/local_ptr.rs @@ -109,7 +109,9 @@ pub mod compiled { /// Does not validate the pointer type. #[inline] pub unsafe fn take<T>() -> ~T { - let ptr: ~T = cast::transmute(RT_TLS_PTR); + let ptr = RT_TLS_PTR; + assert!(!ptr.is_null()); + let ptr: ~T = cast::transmute(ptr); // can't use `as`, due to type not matching with `cfg(test)` RT_TLS_PTR = cast::transmute(0); ptr |
