Hi Tim,
On Tue, Jun 23, 2020 at 05:06:27PM +0200, Tim Duesterhus wrote:
> Otherwise `arg++` will be executed for every argument after the maximum,
> returning a bogus value.
No, it returns the correct one, as documented at the beginning of the
function:
... <args> are not updated beyond <nbargs> but the returned <nbargs>
indicates how many were found.
The purpose was to allow the caller to realloc() its array if it wants
to read all the args. I couldn't find a single case where this arg is
dereferenced inside the function so for me it's OK, but I could very
well miss something.
I think the problem you've spotted is entirely related to what you've
fixed in the second patch in fact. Instead of args[arg-1] we need to
use args[MAX_LINE_ARGS-1] which is the limit we've passed to the
function. And of course your change from thisline to outline is right.
Willy