This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix memory leak in printf_positional
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Paul Pluzhnikov <ppluzhnikov at google dot com>
- Cc: Carlos O'Donell <carlos at redhat dot com>, Paul Eggert <eggert at cs dot ucla dot edu>, GLIBC Devel <libc-alpha at sourceware dot org>
- Date: Wed, 2 Sep 2015 10:07:55 +0000
- Subject: Re: [PATCH] Fix memory leak in printf_positional
- Authentication-results: sourceware.org; auth=none
- References: <1440571295-20230-1-git-send-email-eggert at cs dot ucla dot edu> <alpine dot DEB dot 2 dot 10 dot 1508260930500 dot 26898 at digraph dot polyomino dot org dot uk> <55DFB7C7 dot 50307 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1508281350520 dot 5939 at digraph dot polyomino dot org dot uk> <55E06924 dot 2000209 at redhat dot com> <CALoOobMkGafD9zvq9g13TM8_Nd+HmC58_8gMGTQhdefXpko3CA at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1508311039110 dot 27932 at digraph dot polyomino dot org dot uk> <CALoOobO2iV9hPNB_S7PDoL=cWVCPrSkKGaUQfqboxUg40fsrVw at mail dot gmail dot com>
On Tue, 1 Sep 2015, Paul Pluzhnikov wrote:
> Well, to show the leak requires positional format, like this:
>
> "%1$s %2$s ..."
>
> However, I was able to use
>
> "%1$s %s %s ..."
That's may be simplest if we think glibc should not have leaks for this
usage. It's possible to produce examples with positional formats using
macros if desired, e.g.:
#define str1(x) #x
#define str(x) str1(x)
#define strc(a,b,c) str(a##b##c)
#define e(x,y,z) "%"strc(x,y,z)"$s "
#define f(x,y) e(x,y,0) e(x,y,1) e(x,y,2) e(x,y,3) e(x,y,4) e(x,y,5) e(x,y,6) e(x,y,7) e(x,y,8) e(x,y,9)
#define g(x) f(x,0) f(x,1) f(x,2) f(x,3) f(x,4) f(x,5) f(x,6) f(x,7) f(x,8) f(x,9)
g(0) g(1) g(2) g(3) g(4) g(5) g(6) g(7) g(8) g(9)
(that example produces numbers with leading 0s, but you can produce
numbers with 1, 2, 3 and 4 digits separately to avoid that).
--
Joseph S. Myers
joseph@codesourcery.com