Usage of unitialized heap in tic4x_print_cond

Tim Rühsen tim.ruehsen@gmx.de
Sun Dec 29 16:32:00 GMT 2019


On 29.12.19 12:41, Alan Modra wrote:
> 	PR 25319
> 	* tic4x-dis.c (tic4x_print_cond): Init all of condtable.
> 
> diff --git a/opcodes/tic4x-dis.c b/opcodes/tic4x-dis.c
> index d9f95c9410..01cfa1e060 100644
> --- a/opcodes/tic4x-dis.c
> +++ b/opcodes/tic4x-dis.c
> @@ -277,7 +277,7 @@ tic4x_print_cond (struct disassemble_info *info, unsigned int cond)
>  
>    if (condtable == NULL)
>      {
> -      condtable = xmalloc (sizeof (tic4x_cond_t *) * 32);
> +      condtable = xcalloc (sizeof (tic4x_cond_t *), 32);
>        for (i = 0; i < tic4x_num_conds; i++)
>  	condtable[tic4x_conds[i].cond] = (tic4x_cond_t *)(tic4x_conds + i);
>      }

Sorry for being nitpicking, but isn't it xcalloc(nmemb, size) ?

Regards, Tim

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20191229/b3aaf88f/attachment.sig>


More information about the Binutils mailing list