2024-02-16 20:02:50 +00:00
|
|
|
//@ needs-sanitizer-support
|
|
|
|
|
//@ needs-sanitizer-address
|
|
|
|
|
//@ ignore-cross-compile
|
2020-03-03 15:04:57 -08:00
|
|
|
//
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ compile-flags: -Z sanitizer=address -O
|
2020-03-03 15:04:57 -08:00
|
|
|
//
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ run-fail
|
|
|
|
|
//@ regex-error-pattern: AddressSanitizer: (SEGV|attempting free on address which was not malloc)
|
2020-03-03 15:04:57 -08:00
|
|
|
|
|
|
|
|
use std::ffi::c_void;
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
fn free(ptr: *mut c_void);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
unsafe {
|
|
|
|
|
free(1 as *mut c_void);
|
|
|
|
|
}
|
|
|
|
|
}
|