Skip to content

Commit

Permalink
Add an extra null pointer test to analysis example
Browse files Browse the repository at this point in the history
Add one test where a function argument can be either
null or non-null in the recur() function of the
analysis/tests/misc example code.
  • Loading branch information
ahomescu committed Jun 15, 2024
1 parent d9c61e0 commit 841a196
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions analysis/tests/misc/src/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ pub unsafe extern "C" fn malloc_wrapper(mut size: size_t) -> *mut libc::c_void {
#[no_mangle]
pub unsafe extern "C" fn recur(x: libc::c_int, s: *mut S) {
if x == 0 {
if s.is_null() {
return;
}
return free(s as *mut libc::c_void);
}

Expand Down Expand Up @@ -122,6 +125,7 @@ pub unsafe extern "C" fn simple() {
let s = *y;
*x = s;
recur(3, x);
recur(3, std::ptr::null_mut());
free(x2 as *mut libc::c_void);
}

Expand Down

0 comments on commit 841a196

Please sign in to comment.