decref owned but empty list in List.concat

This commit is contained in:
Folkert 2022-12-28 23:21:31 +01:00
parent 2dfa7d6ef1
commit 05e23f8c5c
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -742,6 +742,9 @@ fn swapElements(source_ptr: [*]u8, element_width: usize, index_1: usize, index_2
pub fn listConcat(list_a: RocList, list_b: RocList, alignment: u32, element_width: usize) callconv(.C) RocList {
// NOTE we always use list_a! because it is owned, we must consume it, and it may have unused capacity
if (list_b.isEmpty()) {
// we must consume this list. Even though it has no elements, it could still have capacity
list_b.deinit(usize);
return list_a;
} else if (list_a.isUnique()) {
const total_length: usize = list_a.len() + list_b.len();