Skip to content

Commit 08adb0c

Browse files
committed
Fix string and uuid allocation assuming pre-constructed value; instead write in-place.
1 parent 01eb50f commit 08adb0c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/interpreter/data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ impl Value {
2727
// TODO The constants should probably be alloced in the chunk's constants, not 'anywhere'.
2828
pub unsafe fn string_to_ptr(string: &String) -> *mut () {
2929
let data = alloc(Layout::new::<String>());
30-
*(data as *mut String) = string.clone();
30+
std::ptr::write(data as *mut String, string.clone());
3131
transmute(data)
3232
}
3333

3434
pub unsafe fn uuid_to_ptr(uuid: Uuid) -> *mut () {
3535
let data = alloc(Layout::new::<Uuid>());
36-
*(data as *mut Uuid) = uuid;
36+
std::ptr::write(data as *mut Uuid, uuid.clone());
3737
transmute(data)
3838
}

0 commit comments

Comments
 (0)