]> Savannah Git Hosting - gnulib.git/commitdiff
argp: avoid extraneous translation and mem leak with empty pre doc
authorAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 2 Dec 2014 16:05:10 +0000 (16:05 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 2 Dec 2014 16:31:34 +0000 (16:31 +0000)
* lib/argp-help.c (argp_doc): Never translate the empty string,
when "\v" is the first or last character of the string, as that
has a reserved meaning to return the header info from a po file.
This also fixes a small memory leak in the !post case.
The issue can be seen with this command for example:
LC_MESSAGES=en_US grub2-mknetdir --help

ChangeLog
lib/argp-help.c

index 2dd5516877dd62b376de599e570b3f7063b6953e..d7911afb4fdb63fd1eb62e182afe015e15e193f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-12-02  Andrei Borzenkov  <arvidjaar@gmail.com>
+
+       argp: avoid extraneous translation and mem leak with empty pre doc
+       * lib/argp-help.c (argp_doc): Never translate the empty string,
+       when "\v" is the first or last character of the string, as that
+       has a reserved meaning to return the header info from a po file.
+       This also fixes a small memory leak in the !post case.
+       The issue can be seen with this command for example:
+       LC_MESSAGES=en_US grub2-mknetdir --help
+
 2014-11-27  Daiki Ueno  <ueno@gnu.org>
 
        uniname/uniname-tests: skip if system's libunistring is used
index 9044e1b1732ce6731e98a9d9835ab69c99ea66ef..f15138b2f26f4c6fbdeba805ced10f2d820b5ee9 100644 (file)
@@ -1506,11 +1506,15 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
       if (vt)
         {
           if (post)
-            inp_text = vt + 1;
+            {
+              inp_text = vt + 1;
+              if (! *inp_text)
+                inp_text = 0;
+            }
           else
             {
               inp_text_len = vt - argp->doc;
-              inp_text = __strndup (argp->doc, inp_text_len);
+              inp_text = inp_text_len ? __strndup (argp->doc, inp_text_len) : 0;
             }
         }
       else