From: Bruno Haible <bruno@clisp.org>
Date: Sat, 5 Jan 2019 16:15:29 +0000 (+0100)
Subject: argp: Don't pass an invalid argument to dgettext().
X-Git-Tag: v1.0~5180
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5f985580b9473b951eff13d92db613d464884091;p=gnulib.git

argp: Don't pass an invalid argument to dgettext().

Reported by He X <xw897002528@gmail.com>.

* lib/argp-help.c (print_header, argp_doc): Don't pass a NULL doc to
dgettext().
---

diff --git a/ChangeLog b/ChangeLog
index 2709cb173d..d05cd8453d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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-help.c (print_header, argp_doc): Don't pass a NULL doc to
+	dgettext().
+
 2019-01-05  Bruno Haible  <bruno@clisp.org>
 
 	argp: Don't pass an invalid argument to dgettext().
diff --git a/lib/argp-help.c b/lib/argp-help.c
index e5e97ecf6c..75abe84dfe 100644
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -1021,7 +1021,7 @@ static void
 print_header (const char *str, const struct argp *argp,
               struct pentry_state *pest)
 {
-  const char *tstr = dgettext (argp->argp_domain, str);
+  const char *tstr = str ? dgettext (argp->argp_domain, str) : NULL;
   const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_HEADER, argp, pest->state);
 
   if (fstr)
@@ -1479,7 +1479,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
   void *input = 0;
   int anything = 0;
   size_t inp_text_limit = 0;
-  const char *doc = dgettext (argp->argp_domain, argp->doc);
+  const char *doc = argp->doc ? dgettext (argp->argp_domain, argp->doc) : NULL;
   const struct argp_child *child = argp->children;
 
   if (doc)