Skip to content

Commit

Permalink
Check for null in return_to_mut. Fixes #4904.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Mar 26, 2013
1 parent 5f52669 commit 0dc6c41
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libcore/unstable/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ pub unsafe fn borrow_as_imm(a: *u8) {
#[lang="return_to_mut"]
#[inline(always)]
pub unsafe fn return_to_mut(a: *u8) {
let a: *mut BoxRepr = transmute(a);
(*a).header.ref_count &= !FROZEN_BIT;
// Sometimes the box is null, if it is conditionally frozen.
// See e.g. #4904.
if !a.is_null() {
let a: *mut BoxRepr = transmute(a);
(*a).header.ref_count &= !FROZEN_BIT;
}
}

#[lang="check_not_borrowed"]
Expand Down

5 comments on commit 0dc6c41

@bors
Copy link
Contributor

@bors bors commented on 0dc6c41 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at nikomatsakis@0dc6c41

@bors
Copy link
Contributor

@bors bors commented on 0dc6c41 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issues-4904-and-4855 = 0dc6c41 into auto

@bors
Copy link
Contributor

@bors bors commented on 0dc6c41 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issues-4904-and-4855 = 0dc6c41 merged ok, testing candidate = d96bbb9

@bors
Copy link
Contributor

@bors bors commented on 0dc6c41 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 0dc6c41 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = d96bbb9

Please sign in to comment.