From cc7ad4bd13bb88ce194270908cc5243b8dc0613a Mon Sep 17 00:00:00 2001 From: Liam Middlebrook Date: Wed, 2 Jun 2021 14:08:10 -0700 Subject: [PATCH] proton: Improve find_nvidia_wine_dll_dir() handling of missing files Additionally split out the find_library() logic for discovery of libdl so that the case of a missing libdl (no matter how unlikely) is caught before attempting to load an erroneous CDLL. Fixes: 4881 (Latest Proton Experimental Fails To Open) Reviewed-by: Adam Moss --- proton | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/proton b/proton index a36c7071..a9cfa2ed 100755 --- a/proton +++ b/proton @@ -148,10 +148,20 @@ def try_get_game_library_dir(): # # On failure, returns None def find_nvidia_wine_dll_dir(): - libdl = CDLL(find_library("libdl")) - libglx_nvidia = CDLL("libGLX_nvidia.so.0") + try: + libdl_soname = find_library("dl") - if libdl is None or libglx_nvidia is None: + # If we couldn't determine the proper soname for libdl, bail out. + if libdl_soname is None: + return None + + libdl = CDLL(libdl_soname) + except (FileNotFoundError, OSError): + return None + + try: + libglx_nvidia = CDLL("libGLX_nvidia.so.0") + except OSError: return None # from dlinfo(3)