]> git.proxmox.com Git - qemu.git/blobdiff - page_cache.c
qdev-properties-system.c: Allow vlan or netdev for -device, not both
[qemu.git] / page_cache.c
index e5717d53c9fb3d5fe2b059e03fa737d11ae3db5b..a05db643ccd711b3cccaf68a6d042f095a6fa247 100644 (file)
@@ -21,7 +21,6 @@
 #include <sys/types.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <strings.h>
 
 #include "qemu-common.h"
 #include "migration/page_cache.h"
@@ -152,11 +151,14 @@ void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata)
     /* actual update of entry */
     it = cache_get_by_addr(cache, addr);
 
+    /* free old cached data if any */
+    g_free(it->it_data);
+
     if (!it->it_data) {
         cache->num_items++;
     }
 
-    it->it_data = pdata;
+    it->it_data = g_memdup(pdata, cache->page_size);
     it->it_age = ++cache->max_item_age;
     it->it_addr = addr;
 }