summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2023-09-11 17:04:20 +0800
committerPeter LaFosse <peter@vector35.com>2023-09-11 13:24:31 -0400
commitf9a9abdff9cc539f5a92c56f8942946a8ac718be (patch)
tree05fce5a4a252c2768d448e5b8b61cb101ad7d125 /python
parentb4da85f227630f8a1d7f4328f45e0f7d3d5a7e29 (diff)
Fix memory leak in functions calling BNCreateUserFunction
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 1a17faa4..01d44471 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -3982,7 +3982,8 @@ class BinaryView:
"""
core.BNRemoveAnalysisFunction(self.handle, func.handle, update_refs)
- def create_user_function(self, addr: int, plat: Optional['_platform.Platform'] = None) -> '_function.Function':
+ def create_user_function(self, addr: int, plat: Optional['_platform.Platform'] = None) \
+ -> Optional['_function.Function']:
"""
``create_user_function`` add a new *user* function of the given ``plat`` at the virtual address ``addr``
@@ -4000,7 +4001,10 @@ class BinaryView:
if self.platform is None:
raise Exception("Attempting to call create_user_function with no specified platform")
plat = self.platform
- return _function.Function(self, core.BNCreateUserFunction(self.handle, plat.handle, addr))
+ func = core.BNCreateUserFunction(self.handle, plat.handle, addr)
+ if func is None:
+ return None
+ return _function.Function(self, func)
def remove_user_function(self, func: '_function.Function') -> None:
"""