diff --git a/qemu/tcg/tcg.c b/qemu/tcg/tcg.c index 9d7b9b17..4910c67c 100644 --- a/qemu/tcg/tcg.c +++ b/qemu/tcg/tcg.c @@ -697,19 +697,18 @@ void uc_add_inline_hook(uc_engine *uc, struct hook *hk, void** args, int args_le tcg_gen_callN(tcg_ctx, info->func, NULL, args_len, (TCGTemp**)args); } -void uc_del_inline_hook(uc_engine *uc, struct hook *hk) +static void uc_free_inline_hook_info(void *p) { - GHashTable *helper_table = uc->tcg_ctx->helper_table; - TCGHelperInfo* info = g_hash_table_lookup(helper_table, hk->callback); + TCGHelperInfo *info = (TCGHelperInfo *)p; - if (info) { - g_hash_table_remove(helper_table, info); - - g_free((gpointer)info->name); - g_free(info); - } + g_free((void*)(info->name)); + g_free(info); } +void uc_del_inline_hook(uc_engine *uc, struct hook *hk) +{ + g_hash_table_remove(uc->tcg_ctx->custom_helper_infos, hk->callback); +} void tcg_context_init(TCGContext *s) { @@ -754,7 +753,7 @@ void tcg_context_init(TCGContext *s) s->helper_table = helper_table; // Unicorn: Store our custom inline hooks infomation - s->custom_helper_infos = g_hash_table_new_full(NULL, NULL, NULL, g_free); + s->custom_helper_infos = g_hash_table_new_full(NULL, NULL, NULL, uc_free_inline_hook_info); for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) { g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,