PR binutils/55326
authorNick Clifton <nickc@redhat.com>
Wed, 9 Jan 2008 10:40:32 +0000 (10:40 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 9 Jan 2008 10:40:32 +0000 (10:40 +0000)
   * bucomm.c (list_supported_architectures): Free architecture list after use.
   * windres.c (set_endianess): Likewise.
   * windmc.c (set_endianess): Likewise.

binutils/ChangeLog
binutils/bucomm.c
binutils/windmc.c
binutils/windres.c

index d3c1d32..0c0efda 100644 (file)
@@ -1,3 +1,11 @@
+2008-01-09  Jakub Zawadzki  <darkjames@darkjames.ath.cx>
+
+       PR binutils/55326
+       * bucomm.c (list_supported_architectures): Free architecture list
+       after use.
+       * windres.c (set_endianess): Likewise.
+       * windmc.c (set_endianess): Likewise.
+
 2008-01-08  Kai Tietz  <kai.tietz@onevision.com>
 
        * binutils/rclex.c: (yylex): Add ':', '_', '\\', and '/' to post
index 26cb09e..508790f 100644 (file)
@@ -195,16 +195,18 @@ list_supported_targets (const char *name, FILE *f)
 void
 list_supported_architectures (const char *name, FILE *f)
 {
-  const char **arch;
+  const char ** arch;
+  const char ** arches;
 
   if (name == NULL)
     fprintf (f, _("Supported architectures:"));
   else
     fprintf (f, _("%s: supported architectures:"), name);
 
-  for (arch = bfd_arch_list (); *arch; arch++)
+  for (arch = arches = bfd_arch_list (); *arch; arch++)
     fprintf (f, " %s", *arch);
   fprintf (f, "\n");
+  free (arches);
 }
 \f
 /* The length of the longest architecture name + 1.  */
index 14a2f86..2c6da42 100644 (file)
@@ -245,18 +245,23 @@ set_endianess (bfd *abfd, const char *target)
   if (! target_vec)
     fatal ("Can't detect target endianess and architecture.");
   target_is_bigendian = ((target_vec->byteorder == BFD_ENDIAN_BIG) ? 1 : 0);
+
   {
-    const char *tname = target_vec->name;
-    const char **arch = bfd_arch_list ();
+    const char *  tname = target_vec->name;
+    const char ** arches = bfd_arch_list ();
 
-    if (arch && tname)
+    if (arches && tname)
       {
+       const char ** arch = arches;
+
        if (strchr (tname, '-') != NULL)
          tname = strchr (tname, '-') + 1;
+
        while (*arch != NULL)
          {
            const char *in_a = strstr (*arch, tname);
            char end_ch = (in_a ? in_a[strlen (tname)] : 0);
+
            if (in_a && (in_a == *arch || in_a[-1] == ':')
                && end_ch == 0)
              {
@@ -266,6 +271,9 @@ set_endianess (bfd *abfd, const char *target)
            arch++;
          }
       }
+
+    free (arches);
+
     if (! def_target_arch)
       fatal ("Can't detect architecture.");
   }
index a4b466c..e68a504 100644 (file)
@@ -1062,7 +1062,8 @@ main (int argc, char **argv)
   return 0;
 }
 
-static void set_endianess (bfd *abfd, const char *target)
+static void
+set_endianess (bfd *abfd, const char *target)
 {
   const bfd_target *target_vec;
 
@@ -1071,17 +1072,22 @@ static void set_endianess (bfd *abfd, const char *target)
   if (! target_vec)
     fatal ("Can't detect target endianess and architecture.");
   target_is_bigendian = ((target_vec->byteorder == BFD_ENDIAN_BIG) ? 1 : 0);
+
   {
-    const char *tname = target_vec->name;
-    const char **arch = bfd_arch_list();
-    if (arch && tname)
+    const char *  tname = target_vec->name;
+    const char ** arches = bfd_arch_list();
+
+    if (arches && tname)
       {
+       const char ** arch = arches;
+
        if (strchr (tname, '-') != NULL)
          tname = strchr (tname, '-') + 1;
        while (*arch != NULL)
          {
            const char *in_a = strstr (*arch, tname);
            char end_ch = (in_a ? in_a[strlen(tname)] : 0);
+
            if (in_a && (in_a == *arch || in_a[-1] == ':')
                && end_ch == 0)
              {
@@ -1091,6 +1097,9 @@ static void set_endianess (bfd *abfd, const char *target)
            arch++;
          }
       }
+
+    free (arches);
+
     if (! def_target_arch)
       fatal ("Can't detect architecture.");
   }
@@ -1156,8 +1165,8 @@ set_windres_bfd (windres_bfd *wrbfd, bfd *abfd, asection *sec, rc_uint_type kind
 }
 
 void
-set_windres_bfd_content(windres_bfd *wrbfd, const void *data, rc_uint_type off,
-                       rc_uint_type length)
+set_windres_bfd_content (windres_bfd *wrbfd, const void *data, rc_uint_type off,
+                        rc_uint_type length)
 {
   if (WR_KIND(wrbfd) != WR_KIND_TARGET)
     {
@@ -1169,8 +1178,8 @@ set_windres_bfd_content(windres_bfd *wrbfd, const void *data, rc_uint_type off,
 }
 
 void
-get_windres_bfd_content(windres_bfd *wrbfd, void *data, rc_uint_type off,
-                       rc_uint_type length)
+get_windres_bfd_content (windres_bfd *wrbfd, void *data, rc_uint_type off,
+                        rc_uint_type length)
 {
   if (WR_KIND(wrbfd) != WR_KIND_TARGET)
     {