From ab4bd0d0617ecc64126dfddb42ed212a65f57a05 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Thu, 6 Jul 2000 07:25:02 +0000 Subject: [PATCH] Always NULL terminate long option list. --- gas/ChangeLog | 4 ++++ gas/as.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index c6eced5e4..588c67917 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,7 @@ +Thu Jul 6 17:20:58 2000 Andrew Cagney + + * as.c (parse_args): NULL terminate the long option list. + Tue Jul 4 14:08:28 2000 Andrew Cagney * config/tc-d30v.h: Include "write.h" for fixS. diff --git a/gas/as.c b/gas/as.c index f22120727..db2181503 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; -- 2.11.4.GIT