Skip to content

Commit 2fa5808

Browse files
committed
std: check if TCS is a null pointer
1 parent 9358d09 commit 2fa5808

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/std/src/sys/sgx/abi/thread.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ use fortanix_sgx_abi::Tcs;
77
#[unstable(feature = "sgx_platform", issue = "56975")]
88
pub fn current() -> Tcs {
99
extern "C" {
10-
fn get_tcs_addr() -> Tcs;
10+
fn get_tcs_addr() -> *mut u8;
11+
}
12+
let addr = unsafe { get_tcs_addr() };
13+
match Tcs::new(addr) {
14+
Some(tcs) => tcs,
15+
None => rtabort!("TCS must not be placed at address zero (this is a linker error)"),
1116
}
12-
unsafe { get_tcs_addr() }
1317
}

0 commit comments

Comments
 (0)