Merge pull request #787 from richo/richo-bytearray

Workaround unicorn handing back bytearrays
This commit is contained in:
Nguyen Anh Quynh 2016-10-06 14:38:31 +08:00 committed by GitHub
commit cd8d2e2cfa

View File

@ -843,6 +843,10 @@ class Cs(object):
print(code)
code = code.encode()
print(code)'''
# Hack, unicorn's memory accessors give you back bytearrays, but they
# cause TypeErrors when you hand them into Capstone.
if isinstance(code, bytearray):
code = bytes(code)
res = _cs.cs_disasm(self.csh, code, len(code), offset, count, ctypes.byref(all_insn))
if res > 0:
try: