fix some leaks torture tests detected 2011-08-30
authorYang Tse <yangsita@gmail.com>
Wed, 31 Aug 2011 01:50:07 +0000 (03:50 +0200)
committerYang Tse <yangsita@gmail.com>
Wed, 31 Aug 2011 01:50:07 +0000 (03:50 +0200)
lib/ftp.c

index 43a72eb..538873a 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -999,8 +999,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
       result = Curl_pp_sendf(&ftpc->pp, "%s |%d|%s|%hu|", mode[fcmd],
                              sa->sa_family == AF_INET?1:2,
                              myhost, port);
-      if(result)
+      if(result) {
+        Curl_closesocket(conn, portsock);
         return result;
+      }
       break;
     }
     else if(PORT == fcmd) {
@@ -1020,8 +1022,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
       snprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff));
 
       result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], tmp);
-      if(result)
+      if(result) {
+        Curl_closesocket(conn, portsock);
         return result;
+      }
       break;
     }
   }