# HG changeset patch # User Andrei Borzenkov # Date 1417536310 0 # Node ID 0806fba611ab3ae0e58af091ab8aeb9f24018bd3 # Parent c8c7d549579ea6b752d0ea2372b16523c563db46 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 diff -r c8c7d549579e -r 0806fba611ab ChangeLog --- a/ChangeLog Sat Nov 29 06:00:25 2014 -0800 +++ b/ChangeLog Tue Dec 02 16:05:10 2014 +0000 @@ -1,3 +1,13 @@ +2014-12-02 Andrei Borzenkov + + 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 uniname/uniname-tests: skip if system's libunistring is used diff -r c8c7d549579e -r 0806fba611ab lib/argp-help.c --- a/lib/argp-help.c Sat Nov 29 06:00:25 2014 -0800 +++ b/lib/argp-help.c Tue Dec 02 16:05:10 2014 +0000 @@ -1506,11 +1506,15 @@ 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