diff --git a/src/tools.c b/src/tools.c index 33bc88e6d..3796c98b1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -5750,7 +5750,13 @@ uint32_t parse_line(char *in, char *out, size_t *outlen, char **args, int *nbarg /* end of output string */ EMIT_CHAR(0); - arg++; + + /* don't add empty arg after trailing spaces. Note that args[arg] + * may contain some distances relative to NULL if was NULL, + * so we test instead of args[arg]. + */ + if (arg < argsmax && out && *(args[arg])) + arg++; if (quote) { /* unmatched quote */