fix: find_library can be None (#7145)

This commit is contained in:
Jacky Lee
2024-10-18 10:50:52 -07:00
committed by GitHub
parent b0a13896d7
commit c8b59416d0
2 changed files with 2 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ class FunctionFactoryStub:
# You can either re-run clan2py with -l /path/to/library.so
# Or manually fix this by comment the ctypes.CDLL loading
_libraries = {}
_libraries['libc'] = ctypes.CDLL(ctypes.util.find_library('c')) # ctypes.CDLL('libc')
_libraries['libc'] = None if (libc_path := ctypes.util.find_library('c')) is None else ctypes.CDLL(libc_path) # ctypes.CDLL('libc')
def string_cast(char_pointer, encoding='utf-8', errors='strict'):
value = ctypes.cast(char_pointer, ctypes.c_char_p).value
if value is not None and encoding is not None: