Skip to contentSkip to conversation

target-ppc: Fix overallocation of opcode tables

PATCH Applied Stuart Brady 3 participants 3 messages Mar 19, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: Fix overallocation of opcode tables

create_new_table() should allocate 0x20 opc_handler_t pointers, but actually allocates 0x20 opc_handler_t structs. Fix this.

---
 translate_init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/translate_init.c +1 -1
index 6084f40..75f34c1 100644
@@ -7434,7 +7434,7 @@ static int create_new_table (opc_handler_t **table, unsigned char idx)
 {
     opc_handler_t **tmp;
 
-    tmp = g_malloc(0x20 * sizeof(opc_handler_t));
+    tmp = g_new(opc_handler_t *, 0x20);
     fill_new_table(tmp, 0x20);
     table[idx] = (opc_handler_t *)((uintptr_t)tmp | PPC_INDIRECT);
 
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 13 lines · Stuart Brady

create_new_table() should allocate 0x20 opc_handler_t pointers, but actually allocates 0x20 opc_handler_t structs. Fix this.

---
 translate_init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/translate_init.c +0 -0
index 6084f40..75f34c1 100644

target-ppc/translate_init.c static int create_new_table (opc_handler_t **table, unsigned char idx) · line 7440

Quoted 8 lines
target-ppc/translate_init.c +1 -1
@@ -7434,7 +7434,7 @@ static int create_new_table (opc_handler_t **table, unsigned char idx)
 {
     opc_handler_t **tmp;
 
-    tmp = g_malloc(0x20 * sizeof(opc_handler_t));
+    tmp = g_new(opc_handler_t *, 0x20);
     fill_new_table(tmp, 0x20);
     table[idx] = (opc_handler_t *)((uintptr_t)tmp | PPC_INDIRECT);
 
#2 lore raw

Am 19.03.2014 16:14, schrieb Tom Musta:

Quoted 8 lines · Stuart Brady
Quoted 4 lines

create_new_table() should allocate 0x20 opc_handler_t pointers, but actually allocates 0x20 opc_handler_t structs. Fix this.

Thanks, applied to my ppc-next:
https://github.com/afaerber/qemu-cpu/commits/ppc-next

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg