From 8539548efa098ef59f35be8224deab5557f3116f Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Sat, 26 Dec 2020 15:49:17 -0800 Subject: [PATCH] Use `strcmp()` to compare `f_lib` and `JL_LIBJULIA_DL_LIBNAME` (#39005) This future-proofs us from someone trying lookup a symbol from `libjulia.dll`, even though that should be quite rare, it may happen. (cherry picked from commit 0af737c5153bd84821ecffbc539f70f5ba6a1087) --- src/runtime_ccall.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime_ccall.cpp b/src/runtime_ccall.cpp index 1f176afac7ebfb..307acc9c28cd16 100644 --- a/src/runtime_ccall.cpp +++ b/src/runtime_ccall.cpp @@ -30,16 +30,16 @@ extern "C" void *jl_get_library_(const char *f_lib, int throw_err) JL_NOTSAFEPOINT { void *hnd; + if (f_lib == NULL) + return jl_RTLD_DEFAULT_handle; #ifdef _OS_WINDOWS_ if (f_lib == JL_EXE_LIBNAME) return jl_exe_handle; if (f_lib == JL_LIBJULIA_INTERNAL_DL_LIBNAME) return jl_libjulia_internal_handle; - if (f_lib == JL_LIBJULIA_DL_LIBNAME) + if (strcmp(f_lib, JL_LIBJULIA_DL_LIBNAME) == 0) return jl_libjulia_handle; #endif - if (f_lib == NULL) - return jl_RTLD_DEFAULT_handle; JL_LOCK_NOGC(&libmap_lock); // This is the only operation we do on the map, which doesn't invalidate // any references or iterators.