mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
Check for null in return_to_mut. Fixes #4904.
This commit is contained in:
@@ -99,8 +99,12 @@ pub unsafe fn borrow_as_imm(a: *u8) {
|
|||||||
#[lang="return_to_mut"]
|
#[lang="return_to_mut"]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn return_to_mut(a: *u8) {
|
pub unsafe fn return_to_mut(a: *u8) {
|
||||||
let a: *mut BoxRepr = transmute(a);
|
// Sometimes the box is null, if it is conditionally frozen.
|
||||||
(*a).header.ref_count &= !FROZEN_BIT;
|
// See e.g. #4904.
|
||||||
|
if !a.is_null() {
|
||||||
|
let a: *mut BoxRepr = transmute(a);
|
||||||
|
(*a).header.ref_count &= !FROZEN_BIT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang="check_not_borrowed"]
|
#[lang="check_not_borrowed"]
|
||||||
|
|||||||
Reference in New Issue
Block a user