Always NULL terminate long option list.
authorAndrew Cagney <cagney@redhat.com>
Thu, 6 Jul 2000 07:25:02 +0000 (07:25 +0000)
committerAndrew Cagney <cagney@redhat.com>
Thu, 6 Jul 2000 07:25:02 +0000 (07:25 +0000)
gas/ChangeLog
gas/as.c

index c6eced5e472ea83341f9c060c7d36b0f82a932fc..588c6791762d0d354d32acc8d9ed221b9fee27aa 100644 (file)
@@ -1,3 +1,7 @@
+Thu Jul  6 17:20:58 2000  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * as.c (parse_args): NULL terminate the long option list.
+
 Tue Jul  4 14:08:28 2000  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * config/tc-d30v.h: Include "write.h" for fixS.
index f22120727ea4e19d97ba000a806b0a6b45761e29..db21815035663b37c563af920679f96a037b3809 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -425,13 +425,18 @@ parse_args (pargc, pargv)
     {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
   };
 
-  /* Construct the option lists from the standard list and the
-     target dependent list.  */
+  /* Construct the option lists from the standard list and the target
+     dependent list.  Include space for an extra NULL option and
+     always NULL terminate. */
   shortopts = concat (std_shortopts, md_shortopts, (char *) NULL);
-  longopts = (struct option *) xmalloc (sizeof (std_longopts) + md_longopts_size);
+  longopts = (struct option *) xmalloc (sizeof (std_longopts)
+                                       + md_longopts_size
+                                       + sizeof (struct option));
   memcpy (longopts, std_longopts, sizeof (std_longopts));
   memcpy ((char *) longopts + sizeof (std_longopts),
          md_longopts, md_longopts_size);
+  memset ((char *) longopts + sizeof (std_longopts) + md_longopts_size,
+         0, sizeof (struct option));
 
   /* Make a local copy of the old argv.  */
   old_argc = *pargc;
This page took 0.028244 seconds and 4 git commands to generate.