We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f2548a0 commit 4bb3f84Copy full SHA for 4bb3f84
turbopack/crates/turbo-tasks-malloc/src/lib.rs
@@ -135,7 +135,10 @@ unsafe impl GlobalAlloc for TurboMalloc {
135
let old_size = unsafe { base_alloc_size(ptr, layout) };
136
let ret = unsafe { base_alloc().realloc(ptr, layout, new_size) };
137
if !ret.is_null() {
138
- let new_size = unsafe { base_alloc_size(ret, layout) };
+ // SAFETY: the caller must ensure that the `new_size` does not overflow.
139
+ // `layout.align()` comes from a `Layout` and is thus guaranteed to be valid.
140
+ let new_layout = unsafe { Layout::from_size_align_unchecked(new_size, layout.align()) };
141
+ let new_size = unsafe { base_alloc_size(ret, new_layout) };
142
update(old_size, new_size);
143
}
144
ret
0 commit comments