[PATCH] stdio: Remove memory leak from multibyte convertion (BZ#25691)

Florian Weimer fw@deneb.enyo.de
Thu Mar 19 21:14:14 GMT 2020


* Adhemerval Zanella via Libc-alpha:

> Co-authored-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

I suggest to put the test into a separate commit.

Is (BZ#25691) recognized by the commit hooks as a bug reference?
I thought it hat to be [BZ #25691] or (bug 25691).

> diff --git a/stdio-common/Makefile b/stdio-common/Makefile
> index 95af0c12d7..0a8d66b846 100644
> --- a/stdio-common/Makefile
> +++ b/stdio-common/Makefile
> @@ -66,6 +66,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
>  	 tst-scanf-round \
>  	 tst-renameat2 tst-bz11319 tst-bz11319-fortify2 \
>  	 scanf14a scanf16a \
> +	 tst-printf-bz25691
>  
>  
>  test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
> @@ -75,10 +76,12 @@ tests-special += $(objpfx)tst-unbputc.out $(objpfx)tst-printf.out \
>  		 $(objpfx)tst-printf-bz18872-mem.out \
>  		 $(objpfx)tst-setvbuf1-cmp.out \
>  		 $(objpfx)tst-vfprintf-width-prec-mem.out \
> -		 $(objpfx)tst-printfsz-islongdouble.out
> +		 $(objpfx)tst-printfsz-islongdouble.out \
> +		 $(objpfx)tst-printf-bz25691-mem.out
>  generated += tst-printf-bz18872.c tst-printf-bz18872.mtrace \
>  	     tst-printf-bz18872-mem.out \
> -	     tst-vfprintf-width-prec.mtrace tst-vfprintf-width-prec-mem.out
> +	     tst-vfprintf-width-prec.mtrace tst-vfprintf-width-prec-mem.out \
> +	     tst-printf-bz25691.mtrace tst-printf-bz25691-mem.out
>  endif
>  
>  include ../Rules
> @@ -100,6 +103,8 @@ endif
>  tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace
>  tst-vfprintf-width-prec-ENV = \
>    MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace
> +tst-printf-bz25691-ENV = \
> +  MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace
>  
>  $(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
>  	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)' > $@; \

Ah, there's a pattern rule matching *-mem.out.  Looks okay.


> diff --git a/stdio-common/tst-printf-bz25691.c b/stdio-common/tst-printf-bz25691.c

> +    /* The input size value is to force a heap allocation on temporary
> +       buffer.  */

> +    /* The input size value is to force a heap allocation on temporary
> +       buffer.  */

I think these comments are now outdated.  Maybe add “(in the old
implementation)”?

> diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
> index 3be92d4b6e..d34e31746c 100644
> --- a/stdio-common/vfprintf-internal.c
> +++ b/stdio-common/vfprintf-internal.c

That part still looks okay to me.  Thanks.


More information about the Libc-alpha mailing list