aboutsummaryrefslogtreecommitdiff
path: root/wcsmbs/wcsmbsload.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-05-21 10:34:21 +0200
committerFlorian Weimer <fweimer@redhat.com>2019-05-21 12:03:54 +0200
commit7e740ab2e7be7d83b75513aa406e0b10875f7f9c (patch)
treeddeb5ddc8c43af310927c3db8b164a91a74ac248 /wcsmbs/wcsmbsload.c
parent09e1b0e3f6facc1af2dbcfef204f0aaa8718772b (diff)
downloadglibc-7e740ab2e7be7d83b75513aa406e0b10875f7f9c.zip
glibc-7e740ab2e7be7d83b75513aa406e0b10875f7f9c.tar.gz
glibc-7e740ab2e7be7d83b75513aa406e0b10875f7f9c.tar.bz2
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 'wcsmbs/wcsmbsload.c')
-rw-r--r--wcsmbs/wcsmbsload.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c
index 5494d0a..10e1a4f 100644
--- a/wcsmbs/wcsmbsload.c
+++ b/wcsmbs/wcsmbsload.c
@@ -265,3 +265,13 @@ _nl_cleanup_ctype (struct __locale_data *locale)
free ((char *) data);
}
}
+
+/* Free the specified conversion functions (but not CONV itself). */
+void
+__wcsmbs_close_conv (struct gconv_fcts *conv)
+{
+ if (conv->towc != &to_wc)
+ __gconv_close_transform (conv->towc, conv->towc_nsteps);
+ if (conv->tomb != &to_mb)
+ __gconv_close_transform (conv->tomb, conv->tomb_nsteps);
+}