diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c --- a/contrib/chg/chg.c +++ b/contrib/chg/chg.c @@ -220,7 +220,10 @@ const char **argv = mallocx(sizeof(char *) * argsize); memcpy(argv, baseargv, sizeof(baseargv)); - memcpy(argv + baseargvsize, opts->args, sizeof(char *) * opts->argsize); + if (opts->args) { + size_t size = sizeof(char *) * opts->argsize; + memcpy(argv + baseargvsize, opts->args, size); + } argv[argsize - 1] = NULL; if (putenv("CHGINTERNALMARK=") != 0)