fix: Handle capacity overflow
This commit is contained in:
parent
6c9ad14e90
commit
0f88c943bf
|
@ -135,6 +135,7 @@ impl Buffer {
|
|||
let new_layout = Layout::from_size_align_unchecked(cap, 1);
|
||||
self.data = alloc(new_layout);
|
||||
} else {
|
||||
assert!(cap <= std::usize::MAX / 2, "capacity is too large");
|
||||
let old_layout = Layout::from_size_align_unchecked(self.capacity, 1);
|
||||
self.data = realloc(self.data, old_layout, cap);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue