Fix memory leak of custom helpers
This commit is contained in:
@ -692,6 +692,7 @@ struct TCGContext {
|
|||||||
TCGOp *icount_start_insn;
|
TCGOp *icount_start_insn;
|
||||||
/* qemu/tcg/tcg.c */
|
/* qemu/tcg/tcg.c */
|
||||||
GHashTable *helper_table;
|
GHashTable *helper_table;
|
||||||
|
GHashTable *custom_helper_infos; // To support inline hooks.
|
||||||
TCGv_ptr cpu_env;
|
TCGv_ptr cpu_env;
|
||||||
struct tcg_region_state region;
|
struct tcg_region_state region;
|
||||||
GTree *tree;
|
GTree *tree;
|
||||||
|
@ -692,6 +692,7 @@ void uc_add_inline_hook(uc_engine *uc, struct hook *hk, void** args, int args_le
|
|||||||
info->sizemask = sizemask;
|
info->sizemask = sizemask;
|
||||||
|
|
||||||
g_hash_table_insert(helper_table, (gpointer)info->func, (gpointer)info);
|
g_hash_table_insert(helper_table, (gpointer)info->func, (gpointer)info);
|
||||||
|
g_hash_table_insert(uc->tcg_ctx->custom_helper_infos, (gpointer)info->func, (gpointer)info);
|
||||||
|
|
||||||
tcg_gen_callN(tcg_ctx, info->func, NULL, args_len, (TCGTemp**)args);
|
tcg_gen_callN(tcg_ctx, info->func, NULL, args_len, (TCGTemp**)args);
|
||||||
}
|
}
|
||||||
@ -752,6 +753,9 @@ void tcg_context_init(TCGContext *s)
|
|||||||
helper_table = g_hash_table_new(NULL, NULL);
|
helper_table = g_hash_table_new(NULL, NULL);
|
||||||
s->helper_table = helper_table;
|
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);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) {
|
for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) {
|
||||||
g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,
|
g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,
|
||||||
(gpointer)&all_helpers[i]);
|
(gpointer)&all_helpers[i]);
|
||||||
|
@ -49,6 +49,7 @@ static void release_common(void *t)
|
|||||||
}
|
}
|
||||||
tcg_pool_reset(s);
|
tcg_pool_reset(s);
|
||||||
g_hash_table_destroy(s->helper_table);
|
g_hash_table_destroy(s->helper_table);
|
||||||
|
g_hash_table_destroy(s->custom_helper_infos);
|
||||||
g_free(s->indirect_reg_alloc_order);
|
g_free(s->indirect_reg_alloc_order);
|
||||||
/* qemu/tcg/tcg/c:4018: img = g_malloc(img_size); */
|
/* qemu/tcg/tcg/c:4018: img = g_malloc(img_size); */
|
||||||
g_free((void *)(s->one_entry->symfile_addr));
|
g_free((void *)(s->one_entry->symfile_addr));
|
||||||
|
Reference in New Issue
Block a user