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 stdio/18820] New: fmemopen may leak memory on failure


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

            Bug ID: 18820
           Summary: fmemopen may leak memory on failure
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: ppluzhnikov at google dot com
  Target Milestone: ---

While fixing PR 18757, I noticed that fmemopen leaks memory via the following
path:

FILE *
__fmemopen (void *buf, size_t len, const char *mode)
{
  cookie_io_functions_t iof;
  fmemopen_cookie_t *c;

  c = (fmemopen_cookie_t *) calloc (sizeof (fmemopen_cookie_t), 1);
  ...

  return _IO_fopencookie (c, mode, iof);
}

If _IO_fopencookie() fails and returns NULL, we leak.

The fix for both issues was here:
https://sourceware.org/ml/libc-alpha/2015-08/msg00315.html
but it needs more work.

I might as well separate the issues.

-- 
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]