This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Avoid out of scope access in hsa-dump.c


Hi,

On Sun, Jul 22 2018, Bernd Edlinger wrote:
> Hi,
>
> this fixes an use of a buffer after the block scope
> in hsa-dump.c: "buf" is assigned to "name" and used after
> the scope ends in a fprintf.
>
> I have not done any real checks, except boot-strapping with
> all languages.
> Is it OK for trunk?

I'd even say it's obvious.  So yes, and thanks for spotting it!

Martin

>
>
> Thanks
> Bernd.
> 2018-07-22  Bernd Edlinger  <bernd.edlinger@hotmail.de>
>
> 	hsa-dump.c (dump_hsa_symbol): Avoid out of scope access to buf.
>
> Index: gcc/hsa-dump.c
> ===================================================================
> --- gcc/hsa-dump.c	(revision 262904)
> +++ gcc/hsa-dump.c	(working copy)
> @@ -776,11 +776,11 @@ static void
>  dump_hsa_symbol (FILE *f, hsa_symbol *symbol)
>  {
>    const char *name;
> +  char buf[64];
>    if (symbol->m_name)
>      name = symbol->m_name;
>    else
>      {
> -      char buf[64];
>        sprintf (buf, "__%s_%i", hsa_seg_name (symbol->m_segment),
>  	       symbol->m_name_number);
>  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]