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 26
26
#endif
27
27
28
28
#if !defined(_WIN32) || defined(__CYGWIN__)
29
+
29
30
#if __has_include(<sys/stat.h>)
30
31
# include < sys/stat.h>
31
32
42
43
#include < dlfcn.h>
43
44
#endif
44
45
46
+ #if __has_include(<mach-o/dyld_priv.h>)
47
+ #include < mach-o/dyld_priv.h>
48
+ #define APPLE_OS_SYSTEM 1
45
49
#else
50
+ #define APPLE_OS_SYSTEM 0
51
+ #endif
52
+
53
+ #else // defined(_WIN32)
54
+
46
55
#define WIN32_LEAN_AND_MEAN
47
56
#define NOMINMAX
48
57
#include < windows.h>
49
58
#include < psapi.h>
50
- #endif
59
+
60
+ #endif // defined(_WIN32)
51
61
52
62
#include < cerrno>
53
63
#include < cstdlib>
@@ -519,7 +529,9 @@ _swift_initRuntimePath(void *) {
519
529
#if APPLE_OS_SYSTEM
520
530
const char *path = dyld_image_path_containing_address (_swift_initRuntimePath);
521
531
522
- runtimePath = ::strdup (path);
532
+ // No need to ::strdup() this, as the return value is guaranteed to remain
533
+ // valid as long as the library is loaded.
534
+ runtimePath = path;
523
535
#elif SWIFT_STDLIB_HAS_DLADDR
524
536
Dl_info dli;
525
537
int ret = ::dladdr ((void *)_swift_initRuntimePath, &dli);
You can’t perform that action at this time.
0 commit comments