Menu

#200 Bug in socket.cpp TCPStream::endStream()

closed
5
2004-10-30
2004-09-28
No

Using version 2.1.2.4 under windows:

The method TCPStream::endStream()

calls delete[] gbuf;
delete[] pbuf;
without checking if they are already set to NULL.

If for any reason endStream() is called twice, this will
cause a severe memory error.

I recomend that a test is added:

if \(gbuf\)

delete[] gbuf;
if (pbuf)
delete[] pbuf;

to avoid this.
I got this problem due to the fact that:

close() and connect() both calls this method.

So if connect() fails:

if\(\!connected\)
\{
    rtn = errno;
    endStream\(\);
    errno = rtn;
    connectError\(\);
    return;
\}

And later on the destructor calls endStream() -> crash!

Discussion

  • David Sugar

    David Sugar - 2004-10-30
    • assigned_to: nobody --> dyfet
    • status: open --> closed-fixed
     
  • David Sugar

    David Sugar - 2004-10-30

    Logged In: YES
    user_id=217

    This should be fixed from last release (1.2.5). It was also true of
    endSerial...

     

Log in to post a comment.