[MPlayer-dev-eng] [PATCHv2 6/8] stream ftp: Create buffers before opening control connection

Alexander Strasser eclipse7 at gmx.net
Sat Nov 17 01:03:52 CET 2012


Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 stream/stream_ftp.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/stream/stream_ftp.c b/stream/stream_ftp.c
index 6d0bbbd..c4d5c84 100644
--- a/stream/stream_ftp.c
+++ b/stream/stream_ftp.c
@@ -432,6 +432,15 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
     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);
 
@@ -443,7 +452,6 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
   // 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);
-- 
1.7.10.2.552.gaa3bb87


More information about the MPlayer-dev-eng mailing list