This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug locale/19012] New: iconv_open leaks memory on error path


https://sourceware.org/bugzilla/show_bug.cgi?id=19012

            Bug ID: 19012
           Summary: iconv_open leaks memory on error path
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: locale
          Assignee: unassigned at sourceware dot org
          Reporter: ppluzhnikov at google dot com
  Target Milestone: ---

Google ref: b/2800961

Test case:

#include <iconv.h>

int main() {
  iconv_t res = iconv_open("UTF8", "SJIS");
  if (res == (iconv_t) -1) return 1;
  iconv_close(res);
  return 0;
}

If glibc is built normally, but iconvdata/SJIS.so is *not* installed on the
target (e.g. to save space), then above program shows a memory leak:

==19518== HEAP SUMMARY:
==19518==     in use at exit: 23 bytes in 2 blocks
==19518==   total heap usage: 2,357 allocs, 2,355 frees, 159,395 bytes
allocated
==19518==
==19518== 7 bytes in 1 blocks are definitely lost in loss record 1 of 2
==19518==    at 0x4A06C3D: malloc (vg_replace_malloc.c:299)
==19518==    by 0x4C94BD9: strdup (strdup.c:42)
==19518==    by 0x4C35FB3: gen_steps (gconv_db.c:264)
==19518==    by 0x4C35FB3: find_derivation (gconv_db.c:663)
==19518==    by 0x4C366EC: __gconv_find_transform (gconv_db.c:764)
==19518==    by 0x4C35224: __gconv_open (gconv_open.c:110)
==19518==    by 0x4C34DD0: iconv_open (iconv_open.c:71)
==19518==    by 0x4006BC: main (t.c:4)
==19518==
==19518== 16 bytes in 1 blocks are definitely lost in loss record 2 of 2
==19518==    at 0x4A06C3D: malloc (vg_replace_malloc.c:299)
==19518==    by 0x4C94BD9: strdup (strdup.c:42)
==19518==    by 0x4C35FC5: gen_steps (gconv_db.c:267)
==19518==    by 0x4C35FC5: find_derivation (gconv_db.c:663)
==19518==    by 0x4C366EC: __gconv_find_transform (gconv_db.c:764)
==19518==    by 0x4C35224: __gconv_open (gconv_open.c:110)
==19518==    by 0x4C34DD0: iconv_open (iconv_open.c:71)
==19518==    by 0x4006BC: main (t.c:4)
==19518==
==19518== LEAK SUMMARY:
==19518==    definitely lost: 23 bytes in 2 blocks


This bug has been present in glibc since at least 2.11.1, but likely much
longer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]