This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: [rfa] as.c - always NULL terminate options list
- To: Nick Clifton <nickc at cygnus dot com>
- Subject: Re: [rfa] as.c - always NULL terminate options list
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Thu, 06 Jul 2000 17:25:32 +1000
- CC: binutils at sourceware dot cygnus dot com, Alan Modra <alan at linuxcare dot com dot au>
- References: <200007052143.OAA01108@elmo.cygnus.com>
I checked in the attatched.
Andrew
Thu Jul 6 17:20:58 2000 Andrew Cagney <cagney@b1.cygnus.com>
* as.c (parse_args): NULL terminate the long option list.
Index: as.c
===================================================================
RCS file: /cvs/src/src/gas/as.c,v
retrieving revision 1.13
diff -p -r1.13 as.c
*** as.c 2000/05/13 12:49:55 1.13
--- as.c 2000/07/06 07:22:19
*************** parse_args (pargc, pargv)
*** 425,437 ****
{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
};
! /* Construct the option lists from the standard list and the
! target dependent list. */
shortopts = concat (std_shortopts, md_shortopts, (char *) NULL);
! longopts = (struct option *) xmalloc (sizeof (std_longopts) + md_longopts_size);
memcpy (longopts, std_longopts, sizeof (std_longopts));
memcpy ((char *) longopts + sizeof (std_longopts),
md_longopts, md_longopts_size);
/* Make a local copy of the old argv. */
old_argc = *pargc;
--- 425,442 ----
{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
};
! /* 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
! + 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;