Skip to content

Commit 5edc5e4

Browse files
committed
Fix crash Python bindings for Transform API.
1 parent 8d91951 commit 5edc5e4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

python/transform.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ def __iter__(self):
3737
count = ctypes.c_ulonglong()
3838
xforms = core.BNGetTransformTypeList(count)
3939
assert xforms is not None, "core.BNGetTransformTypeList returned None"
40-
try:
41-
for i in range(0, count.value):
42-
yield Transform(xforms[i])
43-
finally:
44-
core.BNFreeTransformTypeList(xforms)
40+
result = []
41+
for i in range(0, count.value):
42+
ptr_addr = ctypes.cast(xforms[i], ctypes.c_void_p).value
43+
handle = ctypes.cast(ptr_addr, type(xforms[i]))
44+
result.append(Transform(handle))
45+
core.BNFreeTransformTypeList(xforms)
46+
for xform in result:
47+
yield xform
4548

4649
def __getitem__(cls, name):
4750
binaryninja._init_plugins()

0 commit comments

Comments
 (0)