about summary refs log tree commit diff
path: root/tests/ui/sanitizer/badfree.rs
blob: b1b02649dccdc0ba53eb5232a1e7ebafd6abd71c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//@ needs-sanitizer-support
//@ needs-sanitizer-address
//@ ignore-cross-compile
//
//@ compile-flags: -Z sanitizer=address -O -C unsafe-allow-abi-mismatch=sanitizer
//
//@ run-fail-or-crash
//@ regex-error-pattern: AddressSanitizer: (SEGV|attempting free on address which was not malloc)

use std::ffi::c_void;

extern "C" {
    fn free(ptr: *mut c_void);
}

fn main() {
    unsafe {
        free(1 as *mut c_void);
    }
}