lib: uninitialized variable (2) (Coverity 1469898)

Previous correction (2c2d5cb397) was not enough,
so now it is ensured that the argument shift is not negative nor zero.

Signed-off-by: F. Aragon <paco@voltanet.io>
This commit is contained in:
paco 2018-06-20 18:25:28 +02:00
parent 2c2d5cb397
commit a6a87d63d0
No known key found for this signature in database
GPG Key ID: FD112A8C7E6A5E4A

View File

@ -261,8 +261,11 @@ void print_version(const char *progname)
char *argv_concat(struct cmd_token **argv, int argc, int shift)
{
int cnt = argc - shift;
const char *argstr[cnt];
int cnt = MAX(argc - shift, 0);
const char *argstr[cnt + 1];
if (!cnt)
return NULL;
for (int i = 0; i < cnt; i++)
argstr[i] = argv[i + shift]->arg;