diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-05-28 13:52:56 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-05-28 13:52:56 +0200 |
| commit | cf8a4b981298105ca1a60b0897917fb804729f4f (patch) | |
| tree | 84fb55477d504b5f6525857bc7715fa84aa2b88b /src | |
| parent | f28e3276e765848c7a1af51010a314c539af427f (diff) | |
Don't crash if SDK not found during ENV fallback.
Diffstat (limited to 'src')
| -rw-r--r-- | src/microsoft_craziness.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/microsoft_craziness.h b/src/microsoft_craziness.h index c3a7c2629..5480f3bea 100644 --- a/src/microsoft_craziness.h +++ b/src/microsoft_craziness.h @@ -93,11 +93,11 @@ String mc_get_env(String key) { } void mc_free(String str) { - gb_free(mc_allocator, str.text); + if (str.len) gb_free(mc_allocator, str.text); } void mc_free(String16 str) { - gb_free(mc_allocator, str.text); + if (str.len) gb_free(mc_allocator, str.text); } void mc_free_all() { @@ -603,11 +603,10 @@ bool find_msvc_install_from_env_vars(Find_Result_Utf8 *result) { // If we haven't found it yet, we can loop through LIB for specific folders //? This may not be robust enough using `um\x64` and `ucrt\x64` if (!sdk_found) { - char const *lib_env = gb_get_env("LIB", mc_allocator); - defer (gb_free(mc_allocator, (void*)lib_env)); - if (lib_env) { - String lib = make_string_c(lib_env); + String lib = mc_get_env(str_lit("LIB")); + defer (mc_free(lib)); + if (lib.len) { // NOTE(WalterPlinge): I don't know if there's a chance for the LIB variable // to be set without a trailing '\' (apart from manually), so we can just // check paths without it (see use of `String end` in the loop below) @@ -669,6 +668,7 @@ bool find_msvc_install_from_env_vars(Find_Result_Utf8 *result) { } bool vs_found = false; + if (result->vs_exe_path.len > 0 && result->vs_library_path.len > 0) { vs_found = true; } @@ -765,8 +765,8 @@ Find_Result_Utf8 find_visual_studio_and_windows_sdk_utf8() { r.vs_exe_path.len > 0 && r.vs_library_path.len > 0; - if (!all_found && !find_msvc_install_from_env_vars(&r)) { - return {}; + if (!all_found) { + find_msvc_install_from_env_vars(&r); } #if 0 |