Remove the static variable in flatviews_init
Or we may get an invalid old (and free-ed) uc instance reference
This commit is contained in:
@ -368,6 +368,8 @@ struct uc_struct {
|
|||||||
int nested_level; // Current nested_level
|
int nested_level; // Current nested_level
|
||||||
|
|
||||||
struct TranslationBlock *last_tb; // The real last tb we executed.
|
struct TranslationBlock *last_tb; // The real last tb we executed.
|
||||||
|
|
||||||
|
FlatView *empty_view; // Static function variable moved from flatviews_init
|
||||||
};
|
};
|
||||||
|
|
||||||
// Metadata stub for the variable-size cpu context used with uc_context_*()
|
// Metadata stub for the variable-size cpu context used with uc_context_*()
|
||||||
|
@ -783,8 +783,6 @@ static void address_space_update_topology_pass(AddressSpace *as,
|
|||||||
|
|
||||||
static void flatviews_init(struct uc_struct *uc)
|
static void flatviews_init(struct uc_struct *uc)
|
||||||
{
|
{
|
||||||
static FlatView *empty_view;
|
|
||||||
|
|
||||||
if (uc->flat_views) {
|
if (uc->flat_views) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -792,13 +790,13 @@ static void flatviews_init(struct uc_struct *uc)
|
|||||||
uc->flat_views = g_hash_table_new_full(NULL, NULL, NULL,
|
uc->flat_views = g_hash_table_new_full(NULL, NULL, NULL,
|
||||||
(GDestroyNotify) flatview_unref);
|
(GDestroyNotify) flatview_unref);
|
||||||
|
|
||||||
if (!empty_view) {
|
if (!uc->empty_view) {
|
||||||
empty_view = generate_memory_topology(uc, NULL);
|
uc->empty_view = generate_memory_topology(uc, NULL);
|
||||||
/* We keep it alive forever in the global variable. */
|
/* We keep it alive forever in the global variable. */
|
||||||
flatview_ref(empty_view);
|
flatview_ref(uc->empty_view);
|
||||||
} else {
|
} else {
|
||||||
g_hash_table_replace(uc->flat_views, NULL, empty_view);
|
g_hash_table_replace(uc->flat_views, NULL, uc->empty_view);
|
||||||
flatview_ref(empty_view);
|
flatview_ref(uc->empty_view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user