[MPlayer-dev-eng] [PATCH 5/7] stream ftp: Create buffers before opening control connection

Alexander Strasser eclipse7 at gmx.net
Sun Nov 11 22:01:31 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 e136da8..0949bfe 100644
--- a/stream/stream_ftp.c
+++ b/stream/stream_ftp.c
@@ -431,6 +431,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);
 
@@ -442,7 +451,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