fix: UB in safe rust!
This commit is contained in:
parent
75e75ec706
commit
0db6b7790d
|
@ -558,14 +558,19 @@ impl CStringList {
|
|||
let mut bytes = vec![];
|
||||
let mut strings = vec![];
|
||||
i.into_iter().for_each(|s| {
|
||||
strings.push(bytes.as_ptr_range().end as *const i8);
|
||||
let start = bytes.len();
|
||||
bytes.extend_from_slice(s.as_ref().as_bytes());
|
||||
bytes.push(0);
|
||||
strings.push(start);
|
||||
});
|
||||
|
||||
let bytes = bytes.into_boxed_slice();
|
||||
Self {
|
||||
strings: strings.into_boxed_slice(),
|
||||
bytes: bytes.into_boxed_slice(),
|
||||
strings: strings
|
||||
.into_iter()
|
||||
.map(|offset| unsafe { bytes.as_ptr().offset(offset as isize) as *const i8 })
|
||||
.collect(),
|
||||
bytes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue