diff options
| author | bors <bors@rust-lang.org> | 2013-09-26 00:30:57 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-26 00:30:57 -0700 |
| commit | a268a1c4bb3867e4f8b050e07fd216e561b50521 (patch) | |
| tree | 7be5f74714167f8fa65c397f28bdb0e0b6028253 /src/libstd/rt | |
| parent | 5adfa1038787cb042ca5bbe634082201d71a3b72 (diff) | |
| parent | 324418f32bd0d82f20dd79327dff1e3c78b719d2 (diff) | |
| download | rust-a268a1c4bb3867e4f8b050e07fd216e561b50521.tar.gz rust-a268a1c4bb3867e4f8b050e07fd216e561b50521.zip | |
auto merge of #9490 : alexcrichton/rust/issue-9487, r=cmr
If there's no TLS key just yet, then there's nothing to unsafely borrow, so continue returning None. This prevents causing the runtime to abort itself when logging before the runtime is fully initialized. Closes #9487 r? @brson
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/local_ptr.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libstd/rt/local_ptr.rs b/src/libstd/rt/local_ptr.rs index 3f9b7fc83df..33384594c57 100644 --- a/src/libstd/rt/local_ptr.rs +++ b/src/libstd/rt/local_ptr.rs @@ -129,12 +129,16 @@ pub unsafe fn unsafe_borrow<T>() -> *mut T { } pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> { - let key = tls_key(); - let void_ptr = tls::get(key); - if void_ptr.is_null() { - None - } else { - Some(void_ptr as *mut T) + match maybe_tls_key() { + Some(key) => { + let void_ptr = tls::get(key); + if void_ptr.is_null() { + None + } else { + Some(void_ptr as *mut T) + } + } + None => None } } |
