From 7e740ab2e7be7d83b75513aa406e0b10875f7f9c Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 21 May 2019 10:34:21 +0200 Subject: 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. --- wcsmbs/wcsmbsload.c | 10 ++++++++++ wcsmbs/wcsmbsload.h | 1 + 2 files changed, 11 insertions(+) (limited to 'wcsmbs') diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c index 5494d0a23e..10e1a4f4f5 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); +} diff --git a/wcsmbs/wcsmbsload.h b/wcsmbs/wcsmbsload.h index 6ccad4b3ba..c2fffbd914 100644 --- a/wcsmbs/wcsmbsload.h +++ b/wcsmbs/wcsmbsload.h @@ -51,6 +51,7 @@ extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name) /* Function used for the `private.cleanup' hook. */ extern void _nl_cleanup_ctype (struct __locale_data *) attribute_hidden; +extern void __wcsmbs_close_conv (struct gconv_fcts *conv) attribute_hidden; #include -- cgit v1.2.1