diff mbox

target-ppc: Fix overallocation of opcode tables

Message ID 20140319140726.GA9192@zubnet.me.uk
State New
Headers show

Commit Message

Stuart Brady March 19, 2014, 2:07 p.m. UTC
create_new_table() should allocate 0x20 opc_handler_t pointers, but
actually allocates 0x20 opc_handler_t structs.  Fix this.

Signed-off-by: Stuart Brady <sdb@zubnet.me.uk>
---
 translate_init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Musta March 19, 2014, 3:14 p.m. UTC | #1
On 3/19/2014 9:07 AM, Stuart Brady wrote:
> create_new_table() should allocate 0x20 opc_handler_t pointers, but
> actually allocates 0x20 opc_handler_t structs.  Fix this.
> 
> Signed-off-by: Stuart Brady <sdb@zubnet.me.uk>
> ---
>  translate_init.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
> index 6084f40..75f34c1 100644
> --- a/target-ppc/translate_init.c
> +++ b/target-ppc/translate_init.c
> @@ -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: Tom Musta <tommusta@gmail.com>
Tested-by: Tom Musta <tommusta@gmail.com>
Andreas Färber March 19, 2014, 10:19 p.m. UTC | #2
Am 19.03.2014 16:14, schrieb Tom Musta:
> On 3/19/2014 9:07 AM, Stuart Brady wrote:
>> create_new_table() should allocate 0x20 opc_handler_t pointers, but
>> actually allocates 0x20 opc_handler_t structs.  Fix this.
>>
>> Signed-off-by: Stuart Brady <sdb@zubnet.me.uk>
> 
> Reviewed-by: Tom Musta <tommusta@gmail.com>
> Tested-by: Tom Musta <tommusta@gmail.com>

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

Andreas
diff mbox

Patch

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 6084f40..75f34c1 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -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);