If the submitted command started with a newline, the number of
arguments was calculated as zero.
char **argv;
size_t n = 0, i, j;
- while ((i = strcspn(p, delim)) && (p += i)) {
- p += strspn(p, delim);
+ p = args + strspn(args, delim);
+ for (;;) {
+ i = strcspn(p, delim);
+ if (!i)
+ break;
+ p += i;
n++;
+ p += strspn(p, delim);
}
*argv_ptr = para_malloc((n + 1) * sizeof(char *));
argv = *argv_ptr;
i = 0;
- p = args;
+ p = args + strspn(args, delim);
while (p) {
argv[i] = p;
j = strcspn(p, delim);