libstdc++/6594: strstreambuf leaks 16 bytes - gcc 3.0.x
edh@twcny.rr.com
edh@twcny.rr.com
Tue May 7 07:56:00 GMT 2002
>Number: 6594
>Category: libstdc++
>Synopsis: strstreambuf leaks 16 bytes - gcc 3.0.x
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue May 07 07:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Ed Hourigan
>Release: gcc 3.0.4
>Organization:
>Environment:
Red Hat Linux 7.2 on x86 processor
>Description:
The default constructor for strstreambuf allocates a
buffer of 16 bytes. If you assign a user supplied
buffer by calling setp(...), then the 16 byte buffer is
not released and the pointer is lost.
I have verified this leak using the linux tool 'memprof'
Sample code:
( I am deriving a class from strstreambuf so I can control
where the output stream goes )
class MyStreambuf : public strstreambuf
{
public:
MyStreambuf()
{
setp( _buffer, _buffer, _buffer+BUFSIZE ); // leak
here!
...
}
private:
static const int BUFSIZE=256;
char _buffer[BUFSIZE];
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list