aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2000-07-06 07:25:02 +0000
committerAndrew Cagney <cagney@redhat.com>2000-07-06 07:25:02 +0000
commitbeb2de9b6154707bebd2fdd24d337a25ac8a638c (patch)
tree584638e2b16e2274e0ed1bd62d9334f99bcbe2f2 /gas
parent24ddb296289548f4991abd3621fb549c5ad6ddfd (diff)
downloadgdb-beb2de9b6154707bebd2fdd24d337a25ac8a638c.zip
gdb-beb2de9b6154707bebd2fdd24d337a25ac8a638c.tar.gz
gdb-beb2de9b6154707bebd2fdd24d337a25ac8a638c.tar.bz2
Always NULL terminate long option list.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog4
-rw-r--r--gas/as.c11
2 files changed, 12 insertions, 3 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index c6eced5..588c679 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -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.
diff --git a/gas/as.c b/gas/as.c
index f221207..db21815 100644
--- 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;