Skip to content

Commit

Permalink
Add a test that deallocates a stack variable (#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhassan-aws authored Aug 29, 2023
1 parent 94eb92b commit 84a39b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/expected/dealloc/stack/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Status: FAILURE\
Description: "free argument must be dynamic object"

VERIFICATION:- FAILED
17 changes: 17 additions & 0 deletions tests/expected/dealloc/stack/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::alloc::{dealloc, Layout};

// This test checks that Kani flags the deallocation of a stack-allocated
// variable

#[kani::proof]
fn check_dealloc_stack() {
let mut x = 6;
let layout = Layout::new::<i32>();
let p = &mut x as *mut i32;
unsafe {
dealloc(p as *mut u8, layout);
}
}

0 comments on commit 84a39b9

Please sign in to comment.