Skip to content

Instantly share code, notes, and snippets.

@laomaiweng
Created July 6, 2019 21:56
Show Gist options
  • Save laomaiweng/8ab4df7eba61307d129e0c24ad51f73a to your computer and use it in GitHub Desktop.
Save laomaiweng/8ab4df7eba61307d129e0c24ad51f73a to your computer and use it in GitHub Desktop.
[IDATag] Fix crash with context menu on offsets not in a func
diff --git a/src/hooks_disas.cpp b/src/hooks_disas.cpp
index 38ad8d0..57b3470 100644
--- a/src/hooks_disas.cpp
+++ b/src/hooks_disas.cpp
@@ -108,11 +108,12 @@ action_state_t idaapi show_context_menu_disas_ah_t::update(action_update_ctx_t *
int idaapi show_context_menu_disas_func_ah_t::activate(action_activation_ctx_t *ctx)
{
Idatag_context_disas_func* context_menu = new Idatag_context_disas_func(ctx);
- if (myModel->is_in_func(ctx->cur_ea))
+ if (myModel->is_in_func(ctx->cur_ea) != BADADDR)
{
context_menu->show();
}
else {
msg("\n[IDATag] Offset not in function. Aborted.");
}
return 0;
@@ -310,7 +311,7 @@ void evt_view_loc_changed_h(Idatag_hook_cview& myHook_CView, va_list args)
}
ea_t func = myModel->is_in_func(curea);
- if (func)
+ if (func != BADADDR)
{
Offset* offset_func = myModel->get_offset(func);
if (offset_func != NULL)
diff --git a/src/model.cpp b/src/model.cpp
index 9f8d577..0b528b4 100644
--- a/src/model.cpp
+++ b/src/model.cpp
@@ -435,7 +435,7 @@ ea_t Idatag_model::is_in_func(ea_t ea) const
func_t* func;
func = get_func(ea);
- if (func == NULL) return -1;
+ if (func == NULL) return BADADDR;
return func->start_ea;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment