mirror of
https://github.com/mandiant/capa.git
synced 2026-06-12 19:11:32 -07:00
fix: initialize f=None before try in load_capa_function_results to prevent UnboundLocalError
If idaapi.get_func() raises before assignment, the except handler previously referenced the unbound variable f, causing a secondary UnboundLocalError that masked the original exception. Also handles the case where get_func() returns None by falling back to idaapi.get_screen_ea() in the error log.
This commit is contained in:
committed by
Willi Ballenthin
parent
a18595bf89
commit
412e6ad725
@@ -48,6 +48,9 @@
|
||||
- fix: remove unreachable backports.functools_lru_cache fallback and dead dependency @williballenthin
|
||||
- fix: Scopes.from_dict uses cls instead of self so subclasses return the correct type @williballenthin
|
||||
- fix: correct wrong dict key in VMRay _compute_monitor_threads assertion (used thread_id instead of process_id) @williballenthin
|
||||
fix: replace assert with isinstance guard in get_callee for invalid MethodSpec tokens @williballenthin
|
||||
- fix: replace assert with isinstance guard in get_callee for invalid MethodSpec tokens @williballenthin
|
||||
- fix: initialize f=None before try block in load_capa_function_results to prevent UnboundLocalError in except handler @williballenthin (SURF-61)
|
||||
- fix: fix unreachable elif for NOT CompoundStatement so NOT rules render children in IDA plugin tree view @williballenthin (SURF-60)
|
||||
- fix: use next(iter(addrs)) instead of addrs.pop() to avoid mutating the feature cache in parse_features_for_tree @williballenthin (SURF-59)
|
||||
- fix: use integer division in get_printable_len for UTF-16 LE operands @williballenthin (SURF-58)
|
||||
|
||||
@@ -1011,12 +1011,14 @@ class CapaExplorerForm(idaapi.PluginForm):
|
||||
update_wait_box("extracting features")
|
||||
|
||||
# resolve function selected in disassembly view
|
||||
f = None
|
||||
try:
|
||||
f = idaapi.get_func(idaapi.get_screen_ea())
|
||||
if f is not None:
|
||||
self.rulegen_current_function = self.rulegen_feature_extractor.get_function(f.start_ea)
|
||||
except Exception as e:
|
||||
logger.exception("Failed to resolve function at address 0x%X (error: %s)", f.start_ea, e)
|
||||
addr = f.start_ea if f else idaapi.get_screen_ea()
|
||||
logger.exception("Failed to resolve function at address 0x%X (error: %s)", addr, e)
|
||||
return False
|
||||
|
||||
if ida_kernwin.user_cancelled():
|
||||
|
||||
Reference in New Issue
Block a user