Skip to content

Commit

Permalink
Close lib to avoid segmentation fault
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister committed Jan 7, 2021
1 parent cbdd2e8 commit bc92eba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/inputstreamhelper/widevine/widevine.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,18 @@ def ia_cdm_path():

def get_lib_version(path):
"""
Determines version of the Widevine library.
Determines version of the Widevine library using the python ctypes module.
Returns empty string if not possible, which might indicate a problematic file/arch mismatch, so this can be used as a check.
"""
from ctypes import CDLL, c_char_p
from _ctypes import dlclose

lib_version = ''
try:
lib = CDLL(compat_path(path))
lib.GetCdmVersion.restype = c_char_p
lib_version = to_unicode(lib.GetCdmVersion())
dlclose(lib._handle) # pylint: disable=protected-access
except (OSError, AttributeError) as exc:
log(4, 'Failed to determine lib version: ' + str(exc))

Expand Down
8 changes: 4 additions & 4 deletions tests/xbmcvfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def rmdir(path):
def translatePath(path):
"""A stub implementation of the xbmc translatePath() function"""
if path.startswith('special://home'):
return path.replace('special://home', os.path.join(os.getcwd(), 'tests/'))
return path.replace('special://home', os.path.join(os.getcwd(), 'tests'))
if path.startswith('special://masterprofile'):
return path.replace('special://masterprofile', os.path.join(os.getcwd(), 'tests/userdata/'))
return path.replace('special://masterprofile', os.path.join(os.getcwd(), 'tests/userdata'))
if path.startswith('special://profile'):
return path.replace('special://profile', os.path.join(os.getcwd(), 'tests/userdata/'))
return path.replace('special://profile', os.path.join(os.getcwd(), 'tests/userdata'))
if path.startswith('special://userdata'):
return path.replace('special://userdata', os.path.join(os.getcwd(), 'tests/userdata/'))
return path.replace('special://userdata', os.path.join(os.getcwd(), 'tests/userdata'))
return path

0 comments on commit bc92eba

Please sign in to comment.