Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / ffmpeg / libavformat / ftp.c
index 66c0665..7faf4a5 100644 (file)
@@ -183,6 +183,9 @@ static int ftp_send_command(FTPContext *s, const char *command,
 {
     int err;
 
+    if (response)
+        *response = NULL;
+
     if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0)
         return err;
     if (!err)
@@ -444,18 +447,20 @@ static int ftp_features(FTPContext *s)
     static const char *enable_utf8_command = "OPTS UTF8 ON\r\n";
     static const int feat_codes[] = {211, 0};
     static const int opts_codes[] = {200, 451};
-    char *feat;
+    char *feat = NULL;
 
     if (ftp_send_command(s, feat_command, feat_codes, &feat) == 211) {
         if (av_stristr(feat, "UTF8"))
             ftp_send_command(s, enable_utf8_command, opts_codes, NULL);
     }
+    av_freep(&feat);
+
     return 0;
 }
 
 static int ftp_connect_control_connection(URLContext *h)
 {
-    char buf[CONTROL_BUFFER_SIZE], opts_format[20], *response = NULL;
+    char buf[CONTROL_BUFFER_SIZE], *response = NULL;
     int err;
     AVDictionary *opts = NULL;
     FTPContext *s = h->priv_data;
@@ -465,8 +470,7 @@ static int ftp_connect_control_connection(URLContext *h)
         ff_url_join(buf, sizeof(buf), "tcp", NULL,
                     s->hostname, s->server_control_port, NULL);
         if (s->rw_timeout != -1) {
-            snprintf(opts_format, sizeof(opts_format), "%d", s->rw_timeout);
-            av_dict_set(&opts, "timeout", opts_format, 0);
+            av_dict_set_int(&opts, "timeout", s->rw_timeout, 0);
         } /* if option is not given, don't pass it and let tcp use its own default */
         err = ffurl_open(&s->conn_control, buf, AVIO_FLAG_READ_WRITE,
                          &h->interrupt_callback, &opts);
@@ -505,7 +509,7 @@ static int ftp_connect_control_connection(URLContext *h)
 static int ftp_connect_data_connection(URLContext *h)
 {
     int err;
-    char buf[CONTROL_BUFFER_SIZE], opts_format[20];
+    char buf[CONTROL_BUFFER_SIZE];
     AVDictionary *opts = NULL;
     FTPContext *s = h->priv_data;
 
@@ -519,8 +523,7 @@ static int ftp_connect_data_connection(URLContext *h)
         /* Open data connection */
         ff_url_join(buf, sizeof(buf), "tcp", NULL, s->hostname, s->server_data_port, NULL);
         if (s->rw_timeout != -1) {
-            snprintf(opts_format, sizeof(opts_format), "%d", s->rw_timeout);
-            av_dict_set(&opts, "timeout", opts_format, 0);
+            av_dict_set_int(&opts, "timeout", s->rw_timeout, 0);
         } /* if option is not given, don't pass it and let tcp use its own default */
         err = ffurl_open(&s->conn_data, buf, h->flags,
                          &h->interrupt_callback, &opts);