diff options
author | Florian Weimer <fweimer@redhat.com> | 2019-05-21 10:34:21 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-05-21 12:03:54 +0200 |
commit | 7e740ab2e7be7d83b75513aa406e0b10875f7f9c (patch) | |
tree | ddeb5ddc8c43af310927c3db8b164a91a74ac248 /libio/iofclose.c | |
parent | 09e1b0e3f6facc1af2dbcfef204f0aaa8718772b (diff) | |
download | glibc-7e740ab2e7be7d83b75513aa406e0b10875f7f9c.tar.gz glibc-7e740ab2e7be7d83b75513aa406e0b10875f7f9c.tar.xz glibc-7e740ab2e7be7d83b75513aa406e0b10875f7f9c.zip |
libio: Fix gconv-related memory leak [BZ #24583]
struct gconv_fcts for the C locale is statically allocated, and __gconv_close_transform deallocates the steps object. Therefore this commit introduces __wcsmbs_close_conv to avoid freeing the statically allocated steps objects.
Diffstat (limited to 'libio/iofclose.c')
-rw-r--r-- | libio/iofclose.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libio/iofclose.c b/libio/iofclose.c index 8a80dd0b78..c03c6cf57c 100644 --- a/libio/iofclose.c +++ b/libio/iofclose.c @@ -26,8 +26,8 @@ #include "libioP.h" #include <stdlib.h> -#include "../iconv/gconv_int.h" #include <shlib-compat.h> +#include <wcsmbs/wcsmbsload.h> int _IO_new_fclose (FILE *fp) @@ -60,11 +60,14 @@ _IO_new_fclose (FILE *fp) /* This stream has a wide orientation. This means we have to free the conversion functions. */ struct _IO_codecvt *cc = fp->_codecvt; - - __libc_lock_lock (__gconv_lock); - __gconv_release_step (cc->__cd_in.__cd.__steps); - __gconv_release_step (cc->__cd_out.__cd.__steps); - __libc_lock_unlock (__gconv_lock); + struct gconv_fcts conv = + { + .towc = cc->__cd_in.__cd.__steps, + .towc_nsteps = cc->__cd_in.__cd.__nsteps, + .tomb = cc->__cd_out.__cd.__steps, + .tomb_nsteps = cc->__cd_out.__cd.__nsteps, + }; + __wcsmbs_close_conv (&conv); } else { |