summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib/argp-help.c4
-rw-r--r--lib/argp.h9
3 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index bb3598a414..2709cb173d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-01-05 Bruno Haible <bruno@clisp.org>
+
+ argp: Don't pass an invalid argument to dgettext().
+ Reported by He X <xw897002528@gmail.com>.
+ * lib/argp.h (struct argp): Clarify that the args_doc field may be NULL.
+ * lib/argp-help.c (argp_args_usage): Don't pass a NULL args_doc to
+ dgettext().
+
2018-12-22 Paul Eggert <eggert@cs.ucla.edu>
stdioext: port to newer 32-bit Android
diff --git a/lib/argp-help.c b/lib/argp-help.c
index e5375a0f04..e5e97ecf6c 100644
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -1412,8 +1412,10 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
char *our_level = *levels;
int multiple = 0;
const struct argp_child *child = argp->children;
- const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0;
+ const char *tdoc =
+ argp->args_doc ? dgettext (argp->argp_domain, argp->args_doc) : NULL;
const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);
+ const char *nl = NULL;
if (fdoc)
{
diff --git a/lib/argp.h b/lib/argp.h
index 317ac034e0..7aba8877dd 100644
--- a/lib/argp.h
+++ b/lib/argp.h
@@ -69,6 +69,9 @@ typedef int error_t;
extern "C" {
#endif
+/* Glibc documentation:
+ https://www.gnu.org/software/libc/manual/html_node/Argp.html */
+
/* A description of a particular option. A pointer to an array of
these is passed in the OPTIONS field of an argp structure. Each option
entry can correspond to one long option and/or one short option; more
@@ -236,9 +239,9 @@ struct argp
ARGP_KEY_ definitions below. */
argp_parser_t parser;
- /* A string describing what other arguments are wanted by this program. It
- is only used by argp_usage to print the "Usage:" message. If it
- contains newlines, the strings separated by them are considered
+ /* If non-NULL, a string describing what other arguments are wanted by this
+ program. It is only used by argp_usage to print the "Usage:" message.
+ If it contains newlines, the strings separated by them are considered
alternative usage patterns, and printed on separate lines (lines after
the first are prefix by " or: " instead of "Usage:"). */
const char *args_doc;