[PATCH] Fix memory leak in printf_positional
Joseph Myers
joseph@codesourcery.com
Wed Sep 2 10:08:00 GMT 2015
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
More information about the Libc-alpha
mailing list