From 382c20cd58a9a73dc1aefb6a2fd240a248b49644 Mon Sep 17 00:00:00 2001 From: Mike Hunhoff Date: Fri, 15 Dec 2023 18:03:43 -0700 Subject: [PATCH] ghidra: fix UnboundLocalError exception (#1881) --- capa/features/extractors/ghidra/file.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/capa/features/extractors/ghidra/file.py b/capa/features/extractors/ghidra/file.py index 118575c1..0e7407b2 100644 --- a/capa/features/extractors/ghidra/file.py +++ b/capa/features/extractors/ghidra/file.py @@ -127,8 +127,10 @@ def extract_file_strings() -> Iterator[Tuple[Feature, Address]]: """extract ASCII and UTF-16 LE strings""" for block in currentProgram().getMemory().getBlocks(): # type: ignore [name-defined] # noqa: F821 - if block.isInitialized(): - p_bytes = capa.features.extractors.ghidra.helpers.get_block_bytes(block) + if not block.isInitialized(): + continue + + p_bytes = capa.features.extractors.ghidra.helpers.get_block_bytes(block) for s in capa.features.extractors.strings.extract_ascii_strings(p_bytes): offset = block.getStart().getOffset() + s.offset