diff --git a/src/os/cpath/cpath.c b/src/os/cpath/cpath.c index a4cdc4e..b7ef7a9 100644 --- a/src/os/cpath/cpath.c +++ b/src/os/cpath/cpath.c @@ -29,16 +29,20 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) { const Str8Node *first_node = wapp_str8_list_get(parts, 0); wapp_str8_copy_str8_capped(dst, first_node->string); + // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of + // MSVC Spectre mitigation warnings const Str8Node *node = first_node; - for (u64 i = 1; i < parts->node_count; ++i) { + u64 node_index = 1; + bool running = true; + while (running && node->next) { node = node->next; if (node->string->size == 0) { continue; } if (dst->size > 0) { - char dst_last = wapp_str8_get(dst, dst->size - 1); - char node_start = wapp_str8_get(node->string, 0); + char dst_last = wapp_str8_get(dst, dst->size - 1); + char node_start = wapp_str8_get(node->string, 0); bool add_path_sep = dst_last != PATH_SEP && node_start != PATH_SEP; if (add_path_sep) { @@ -47,6 +51,9 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) { } wapp_str8_concat_capped(dst, node->string); + + ++node_index; + running = node_index < parts->node_count; } return CPATH_JOIN_SUCCESS;