# HG changeset patch # User al # Date 1353450124 0 # Node ID 4fe8922d6242fb7984130dcb92b826f14cb416e8 # Parent 6641819c8f45b7bbb5965db918c5fb8824055b9c stream ftp: Create buffers before opening control connection diff -r 6641819c8f45 -r 4fe8922d6242 stream/stream_ftp.c --- a/stream/stream_ftp.c Tue Nov 20 22:20:52 2012 +0000 +++ b/stream/stream_ftp.c Tue Nov 20 22:22:04 2012 +0000 @@ -430,6 +430,15 @@ return STREAM_ERROR; } + // Allocate buffers + p->buf = malloc(BUFSIZE); + + if (!p->buf) { + close_f(stream); + m_struct_free(&stream_opts,opts); + return STREAM_ERROR; + } + // Open the control connection p->handle = connect2Server(p->host,p->port,1); @@ -441,7 +450,6 @@ // We got a connection, let's start serious things stream->fd = -1; stream->priv = p; - p->buf = malloc(BUFSIZE); if (readresp(p, NULL) == 0) { close_f(stream);