Fix a memory leak in mmio

This commit is contained in:
lazymio 2021-11-16 22:44:03 +01:00
parent fc467edbc6
commit c1106b811b
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873

View File

@ -82,6 +82,7 @@ typedef struct _mmio_cbs {
void *user_data_read;
uc_cb_mmio_write_t write;
void *user_data_write;
MemoryRegionOps ops;
} mmio_cbs;
static uint64_t mmio_read_wrapper(struct uc_struct *uc, void *opaque, hwaddr addr, unsigned size)
@ -118,8 +119,8 @@ MemoryRegion *memory_map_io(struct uc_struct *uc, ram_addr_t begin, size_t size,
void *user_data_read, void *user_data_write)
{
MemoryRegion *mmio = g_new(MemoryRegion, 1);
MemoryRegionOps *ops = g_new(MemoryRegionOps, 1);
mmio_cbs* opaques = g_new(mmio_cbs, 1);
MemoryRegionOps *ops = &opaques->ops;
opaques->read = read_cb;
opaques->write = write_cb;
opaques->user_data_read = user_data_read;