From: imp Date: Wed, 11 Sep 2019 13:34:19 +0000 (+0000) Subject: Assume all the short args have optional args so allocate space for the X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=db9a07c32c9adcce9563e17c401e20df1ef0e2b6;p=freebsd.git Assume all the short args have optional args so allocate space for the ':'. It's slightly wasteful, but much easier (and the savings in bytes at runtime would be tiny, but the code to do it larger). Submitted by: Sebastian Huber --- diff --git a/sbin/nvmecontrol/comnd.c b/sbin/nvmecontrol/comnd.c index d8d97ad11b5..4233384eb1e 100644 --- a/sbin/nvmecontrol/comnd.c +++ b/sbin/nvmecontrol/comnd.c @@ -189,7 +189,7 @@ arg_parse(int argc, char * const * argv, const struct cmd *f) lopts = malloc((n + 2) * sizeof(struct option)); if (lopts == NULL) err(1, "option memory"); - p = shortopts = malloc((n + 3) * sizeof(char)); + p = shortopts = malloc((2 * n + 3) * sizeof(char)); if (shortopts == NULL) err(1, "shortopts memory"); idx = 0;