mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
iconv: Revert steps array reference counting changes
The changes introduce a memory leak for gconv steps arrays whose first element is an internal conversion, which has a fixed reference count which is not decremented. As a result, after the change in commit50ce3eae5b
, the steps array is never freed, resulting in an unbounded memory leak. This reverts commit50ce3eae5b
("gconv: Check reference count in __gconv_release_cache [BZ #24677]") and commit7e740ab2e7
("libio: Fix gconv-related memory leak [BZ #24583]"). It reintroduces bug 24583. (Bug 24677 was just a regression caused by the second commit.)
This commit is contained in:
@ -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,14 +60,11 @@ _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;
|
||||
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);
|
||||
|
||||
__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);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user