浏览代码

libobs: Use RTLD_FIRST when loading libraries on macOS

Ensures that functions loaded by `os_dlsym()` come only from the
specified library that was loaded with `os_dlopen()` rather than the set
of libraries loaded by the specified library.
mntone 8 年之前
父节点
当前提交
a66ad7eb63
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      libobs/util/platform-nix.c

+ 4 - 0
libobs/util/platform-nix.c

@@ -67,7 +67,11 @@ void *os_dlopen(const char *path)
 #endif
 #endif
 		dstr_cat(&dylib_name, ".so");
 		dstr_cat(&dylib_name, ".so");
 
 
+#ifdef __APPLE__
+	void *res = dlopen(dylib_name.array, RTLD_LAZY | RTLD_FIRST);
+#else
 	void *res = dlopen(dylib_name.array, RTLD_LAZY);
 	void *res = dlopen(dylib_name.array, RTLD_LAZY);
+#endif
 	if (!res)
 	if (!res)
 		blog(LOG_ERROR, "os_dlopen(%s->%s): %s\n",
 		blog(LOG_ERROR, "os_dlopen(%s->%s): %s\n",
 				path, dylib_name.array, dlerror());
 				path, dylib_name.array, dlerror());