Group :: Sistema/Bibliotecas
RPM: libpopt
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: popt-1.18-alt-poptBadOption.patch
Download
Download
diff --git a/popt/src/popt.c b/popt/src/popt.c
index 2db2bbd..f93971e 100644
--- a/popt/src/popt.c
+++ b/popt/src/popt.c
@@ -1602,20 +1602,23 @@ int poptAddItem(poptContext con, poptItem newItem, int flags)
const char * poptBadOption(poptContext con, unsigned int flags)
{
- struct optionStackEntry * os = NULL;
- const char *badOpt = NULL;
-
- if (con != NULL) {
- /* Stupid hack to return something semi-meaningful from exec failure */
- if (con->execFail) {
- badOpt = con->execFail;
- } else {
- os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
- badOpt = os->argv[os->next - 1];
- }
- }
+ struct optionStackEntry * os;
+
+ if (!con)
+ return NULL;
+
+ /* Stupid hack to return something semi-meaningful from exec failure */
+ if (con->execFail)
+ return con->execFail;
+
+ os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
+ if (!os)
+ return NULL;
+
+ if (con->doExec && con->doExec->argv && !os->nextCharArg && os->next == os->argc)
+ return con->doExec->argv[0];
- return badOpt;
+ return ((os->argv && (os->next > 0)) ? os->argv[os->next - 1] : NULL);
}
const char * poptStrerror(const int error)