File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 2626#endif
2727
2828#if !defined(_WIN32) || defined(__CYGWIN__)
29+
2930#if __has_include(<sys/stat.h>)
3031# include < sys/stat.h>
3132
4243 #include < dlfcn.h>
4344#endif
4445
46+ #if __has_include(<mach-o/dyld_priv.h>)
47+ #include < mach-o/dyld_priv.h>
48+ #define APPLE_OS_SYSTEM 1
4549#else
50+ #define APPLE_OS_SYSTEM 0
51+ #endif
52+
53+ #else // defined(_WIN32)
54+
4655#define WIN32_LEAN_AND_MEAN
4756#define NOMINMAX
4857#include < windows.h>
4958#include < psapi.h>
50- #endif
59+
60+ #endif // defined(_WIN32)
5161
5262#ifdef __linux__
5363// Needed for 'readlink'.
@@ -524,7 +534,9 @@ _swift_initRuntimePath(void *) {
524534#if APPLE_OS_SYSTEM
525535 const char *path = dyld_image_path_containing_address (_swift_initRuntimePath);
526536
527- runtimePath = ::strdup (path);
537+ // No need to ::strdup() this, as the return value is guaranteed to remain
538+ // valid as long as the library is loaded.
539+ runtimePath = path;
528540#elif SWIFT_STDLIB_HAS_DLADDR
529541 Dl_info dli;
530542 int ret = ::dladdr ((void *)_swift_initRuntimePath, &dli);
You can’t perform that action at this time.
0 commit comments