Skip to content

Commit 5f6d0a4

Browse files
committed
Check that GCX_PTR is valid
1 parent 3ca199f commit 5f6d0a4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/librustc/ty/context.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,9 @@ pub mod tls {
19001900
pub unsafe fn with_global<F, R>(f: F) -> R
19011901
where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'a, 'gcx, 'tcx>) -> R
19021902
{
1903-
let gcx = &*(GCX_PTR.with(|lock| *lock.lock()) as *const GlobalCtxt<'_>);
1903+
let gcx = GCX_PTR.with(|lock| *lock.lock());
1904+
assert!(gcx != 0);
1905+
let gcx = &*(gcx as *const GlobalCtxt<'_>);
19041906
let tcx = TyCtxt {
19051907
gcx,
19061908
interners: &gcx.global_interners,

0 commit comments

Comments
 (0)