Don't resize user alloc-ed memory

This commit is contained in:
mio 2022-09-25 17:41:09 +02:00
parent be8c7d018d
commit 32a3a6865a
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873
1 changed files with 6 additions and 2 deletions

View File

@ -1087,8 +1087,12 @@ RAMBlock *qemu_ram_alloc_from_ptr(struct uc_struct *uc, ram_addr_t size, void *h
RAMBlock *new_block; RAMBlock *new_block;
ram_addr_t max_size = size; ram_addr_t max_size = size;
size = HOST_PAGE_ALIGN(uc, size); // Don't resize pre-alloced memory as they are given by users.
max_size = HOST_PAGE_ALIGN(uc, max_size); if (!host) {
size = HOST_PAGE_ALIGN(uc, size);
max_size = HOST_PAGE_ALIGN(uc, max_size);
}
new_block = g_malloc0(sizeof(*new_block)); new_block = g_malloc0(sizeof(*new_block));
if (new_block == NULL) if (new_block == NULL)
return NULL; return NULL;