mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
Properly handle the case where src==dst in upcall_vec_append.
This commit is contained in:
parent
36fb754476
commit
8ad7f3b56b
@ -478,6 +478,12 @@ upcall_vec_append(rust_task *task, type_desc *t, type_desc *elem_t,
|
||||
size_t n_dst_bytes = skip_null ? dst->fill - 1 : dst->fill;
|
||||
rust_vec *new_vec = vec_grow(task, dst, n_src_bytes, &need_copy, t);
|
||||
|
||||
// If src and dst are the same (due to "v += v"), then dst getting
|
||||
// resized causes src to move as well.
|
||||
if (dst == src) {
|
||||
src = new_vec;
|
||||
}
|
||||
|
||||
if (need_copy) {
|
||||
// Copy any dst elements in, omitting null if doing str.
|
||||
copy_elements(task, elem_t, &new_vec->data, &dst->data, n_dst_bytes);
|
||||
|
Loading…
Reference in New Issue
Block a user