reject deallocation of read-only allocations

This commit is contained in:
Ralf Jung 2021-05-23 11:53:23 +02:00
parent 6e92fb4098
commit 3bcba11c35

View File

@ -321,6 +321,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
} }
}; };
if alloc.mutability == Mutability::Not {
throw_ub_format!("deallocating immutable allocation {}", ptr.alloc_id);
}
if alloc_kind != kind { if alloc_kind != kind {
throw_ub_format!( throw_ub_format!(
"deallocating {}, which is {} memory, using {} deallocation operation", "deallocating {}, which is {} memory, using {} deallocation operation",