List.remove_at would incorrectly trigger ASAN.

This commit is contained in:
Christoffer Lerno
2025-08-01 23:43:18 +02:00
parent e3a8a3ec02
commit 90c339ebdb
3 changed files with 22 additions and 3 deletions

View File

@@ -137,9 +137,10 @@ fn Type? List.pop_first(&self)
*>
fn void List.remove_at(&self, usz index)
{
self.set_size(self.size - 1);
if (!self.size || index == self.size) return;
self.entries[index .. self.size - 1] = self.entries[index + 1 .. self.size];
usz new_size = self.size - 1;
defer self.set_size(new_size);
if (!new_size || index == new_size) return;
self.entries[index .. new_size - 1] = self.entries[index + 1 .. new_size];
}
fn void List.add_all(&self, List* other_list)