coffcode.h uses non-ISO-C: int a[f()];

Andrew Cagney ac131313@cygnus.com
Tue Feb 15 17:43:00 GMT 2000


Geoff Keating wrote:
> 

> bfd_malloc() / bfd_free().
> 
> I have a patch for this, which I'd forgotten about.

Thanks!

> OK to commit?

Not my problem :-)  I see Ian's approved it.

	Andrew

> 
> --
> - Geoffrey Keating <geoffk@cygnus.com>
> 
> ===File ~geoffkc/patches/rs6000-coffcodearray.patch=========
> 2000-02-12  Geoff Keating  <geoffk@cygnus.com>
> 
>         * coffcode.h (coff_set_arch_mach_hook): Don't use variable-size
>         arrays.
> 
> Index: coffcode.h
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/bfd/coffcode.h,v
> retrieving revision 1.344.8.1
> retrieving revision 1.344.8.2
> diff -u -r1.344.8.1 -r1.344.8.2
> --- coffcode.h  2000/02/05 16:43:05     1.344.8.1
> +++ coffcode.h  2000/02/14 05:16:18     1.344.8.2
> @@ -1561,17 +1561,23 @@
>               cputype = 0;
>             else
>               {
> -               bfd_byte buf[bfd_coff_symesz (abfd)];
> +               bfd_byte *buf;
>                 struct internal_syment sym;
> 
> +               buf = (bfd_byte *) bfd_malloc (bfd_coff_symesz (abfd));
>                 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
> -                   || bfd_read (buf, 1, bfd_coff_symesz (abfd), abfd) != bfd_coff_symesz (abfd))
> -                 return false;
> +                   || (bfd_read (buf, 1, bfd_coff_symesz (abfd), abfd)
> +                       != bfd_coff_symesz (abfd)))
> +                 {
> +                   bfd_free (buf);
> +                   return false;
> +                 }
>                 coff_swap_sym_in (abfd, (PTR) buf, (PTR) &sym);
>                 if (sym.n_sclass == C_FILE)
>                   cputype = sym.n_type & 0xff;
>                 else
>                   cputype = 0;
> +               bfd_free (buf);
>               }
>           }
> 
> ============================================================


More information about the Binutils mailing list