Fix MSVC Spectre warnings

This commit is contained in:
2025-05-04 23:59:50 +01:00
parent 12f083edb0
commit 2156d2ff3a
7 changed files with 8804 additions and 8423 deletions

View File

@@ -5,12 +5,20 @@
wapp_{Tlower}_array_clear(dst);
{T} *item;
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
for (u64 i = 0; i < to_copy; ++i) {{
item = wapp_{Tlower}_array_get(src, i);
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
u64 item_index = 0;
bool running = true;
while (running) {{
item = wapp_{Tlower}_array_get(src, item_index);
++item_index;
running = item_index < to_copy;
if (!item) {{
continue;
}}
wapp_{Tlower}_array_append_capped(dst, *item);
}}