Unverified Commit d77159c5 by Enkelmann Committed by GitHub

Prevent false double free warnings for parameter objects (#311)

parent 32aad93c
...@@ -153,13 +153,8 @@ impl AbstractObject { ...@@ -153,13 +153,8 @@ impl AbstractObject {
} }
/// Mark the memory object as freed. /// Mark the memory object as freed.
/// Returns an error if a possible double free is detected /// Returns an error if a possible double free is detected.
/// or the memory object may not be a heap object.
pub fn mark_as_freed(&mut self) -> Result<(), Error> { pub fn mark_as_freed(&mut self) -> Result<(), Error> {
if self.inner.type_ != Some(ObjectType::Heap) {
self.set_state(ObjectState::Flagged);
return Err(anyhow!("Free operation on possibly non-heap memory object"));
}
let inner = Arc::make_mut(&mut self.inner); let inner = Arc::make_mut(&mut self.inner);
match (inner.is_unique, inner.state) { match (inner.is_unique, inner.state) {
(true, ObjectState::Alive) | (true, ObjectState::Flagged) => { (true, ObjectState::Alive) | (true, ObjectState::Flagged) => {
...@@ -182,13 +177,8 @@ impl AbstractObject { ...@@ -182,13 +177,8 @@ impl AbstractObject {
} }
/// Mark the memory object as possibly (but not definitely) freed. /// Mark the memory object as possibly (but not definitely) freed.
/// Returns an error if the object was definitely freed before /// Returns an error if the object was definitely freed before.
/// or if the object may not be a heap object.
pub fn mark_as_maybe_freed(&mut self) -> Result<(), Error> { pub fn mark_as_maybe_freed(&mut self) -> Result<(), Error> {
if self.inner.type_ != Some(ObjectType::Heap) {
self.set_state(ObjectState::Flagged);
return Err(anyhow!("Free operation on possibly non-heap memory object"));
}
let inner = Arc::make_mut(&mut self.inner); let inner = Arc::make_mut(&mut self.inner);
match inner.state { match inner.state {
ObjectState::Dangling => { ObjectState::Dangling => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment