1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

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.
This commit is contained in:
Florian Weimer
2019-05-21 10:34:21 +02:00
parent 09e1b0e3f6
commit 7e740ab2e7
7 changed files with 143 additions and 8 deletions

View File

@ -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
{