From 368407b09eba7c5d09689ac81eaadd1645820edd Mon Sep 17 00:00:00 2001 From: Alexander Khosrowshahi Date: Mon, 2 Jun 2025 17:35:28 -0400 Subject: Fix calls to BNFreeString in kernel cache API Amends calls to BNFreeString in kernel cache API that were causing `get_macho_header_for_address`, `get_macho_header_for_image`, `get_image_name_for_address`, and `get_name_for_address` to fail. Fixes https://github.com/Vector35/binaryninja-api/issues/6855 --- view/kernelcache/api/python/kernelcache.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'view/kernelcache/api/python/kernelcache.py') diff --git a/view/kernelcache/api/python/kernelcache.py b/view/kernelcache/api/python/kernelcache.py index 2148f2a8..9425ef9c 100644 --- a/view/kernelcache/api/python/kernelcache.py +++ b/view/kernelcache/api/python/kernelcache.py @@ -207,15 +207,10 @@ class KernelCache: """ Return a KernelCacheMachOHeader for the image with the given install name. """ - s = BNAllocString(name) - outputStr = kccore.BNKCViewGetImageHeaderForName(self.handle, s) + outputStr = kccore.BNKCViewGetImageHeaderForName(self.handle, name) if outputStr is None: return None - output = outputStr - BNFreeString(outputStr) - if output == "": - return None - return KernelCacheMachOHeader.LoadFromString(output) + return KernelCacheMachOHeader.LoadFromString(outputStr) def get_macho_header_for_address(self, address: int): """ @@ -224,11 +219,7 @@ class KernelCache: outputStr = kccore.BNKCViewGetImageHeaderForAddress(self.handle, address) if outputStr is None: return None - output = outputStr - BNFreeString(outputStr) - if output == "": - return None - return KernelCacheMachOHeader.LoadFromString(output) + return KernelCacheMachOHeader.LoadFromString(outputStr) @property def state(self): -- cgit v1.3.1