Skip to content

Commit 3ccc544

Browse files
authored
Merge pull request #80 from 00xc/fuzz/fix-ub
fuzz: remove potential undefined behavior in chaos harness
2 parents 3c9bafa + a5d8f2d commit 3ccc544

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fuzz/fuzz_targets/chaos.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use arbitrary::Arbitrary;
33
use libfuzzer_sys::fuzz_target;
44
use linked_list_allocator::Heap;
55
use std::alloc::Layout;
6-
use std::ptr::NonNull;
6+
use std::ptr::{addr_of, NonNull};
77

88
#[derive(Debug, Arbitrary)]
99
enum Action {
@@ -81,8 +81,8 @@ fn fuzz(size: u16, actions: Vec<Action>) {
8181
Extend { additional } =>
8282
// safety: new heap size never exceeds MAX_HEAP_SIZE
8383
unsafe {
84-
let remaining_space = HEAP_MEM
85-
.as_mut_ptr()
84+
let remaining_space = addr_of!(HEAP_MEM)
85+
.cast::<u8>()
8686
.add(MAX_HEAP_SIZE)
8787
.offset_from(heap.top());
8888
assert!(remaining_space >= 0);

0 commit comments

Comments
 (0)