Skip to content

Commit

Permalink
only report arg to callback when relevant
Browse files Browse the repository at this point in the history
When calling the callback, the value passed in arg is only valid
if the option->argInfo being evaluated is not POPT_ARG_NONE.

Fixes: #76
  • Loading branch information
carenas authored and pmatilai committed Aug 21, 2024
1 parent cff3d07 commit 840cc9d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/popt.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void invokeCallbacksOPTION(poptContext con,
!strcmp(myOpt->longName, opt->longName)))
{ const void *cbData = (cbopt->descrip ? cbopt->descrip : myData);
cbarg.cb(con, POPT_CALLBACK_REASON_OPTION,
myOpt, con->os->nextArg, cbData);
myOpt, myOpt->argInfo ? con->os->nextArg : NULL, cbData);
/* Terminate (unless explicitly continuing). */
if (!CBF_ISSET(cbopt, CONTINUE))
return;
Expand Down

0 comments on commit 840cc9d

Please sign in to comment.