Skip to content

Commit

Permalink
python: shared library can be unloaded from under our feet. issue rep…
Browse files Browse the repository at this point in the history
…orted by @joelpx
  • Loading branch information
aquynh committed Jun 4, 2015
1 parent 8bd0fdb commit 46ab570
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,13 @@ def __init__(self, arch, mode):

# destructor to be called automatically when object is destroyed.
def __del__(self):
if self.csh and _cs is not None:
status = _cs.cs_close(ctypes.byref(self.csh))
if status != CS_ERR_OK:
raise CsError(status)
if self.csh:
try:
status = _cs.cs_close(ctypes.byref(self.csh))
if status != CS_ERR_OK:
raise CsError(status)
except: # _cs might be pulled from under our feet
pass


# def option(self, opt_type, opt_value):
Expand Down

0 comments on commit 46ab570

Please sign in to comment.