]> xenbits.xensource.com Git - freebsd.git/commitdiff
Assume all the short args have optional args so allocate space for the
authorimp <imp@FreeBSD.org>
Wed, 11 Sep 2019 13:34:19 +0000 (13:34 +0000)
committerimp <imp@FreeBSD.org>
Wed, 11 Sep 2019 13:34:19 +0000 (13:34 +0000)
':'. 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

sbin/nvmecontrol/comnd.c

index d8d97ad11b5be0d5f61bcf5f993557ea24c354dd..4233384eb1e3b1789b6523350579301fcab989c9 100644 (file)
@@ -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;