transport_write sometimes returns directly without cleanup. Fix code path to always...
authorzihao.jiang <zihao.jiang@yahoo.com>
Mon, 6 Apr 2015 16:24:08 +0000 (00:24 +0800)
committerzihao.jiang <zihao.jiang@yahoo.com>
Wed, 8 Apr 2015 13:20:07 +0000 (21:20 +0800)
libfreerdp/core/transport.c

index ffda7e2..2ffb757 100644 (file)
@@ -591,16 +591,17 @@ int transport_write(rdpTransport* transport, wStream* s)
                         * is a SSL or TSG BIO in the chain.
                         */
                        if (!BIO_should_retry(transport->frontBio))
-                               return status;
+                               goto out_cleanup;
 
                        /* non-blocking can live with blocked IOs */
                        if (!transport->blocking)
-                               return status;
+                               goto out_cleanup;
 
                        if (BIO_wait_write(transport->frontBio, 100) < 0)
                        {
                                WLog_ERR(TAG, "error when selecting for write");
-                               return -1;
+                               status = -1;
+                               goto out_cleanup;
                        }
 
                        continue;
@@ -613,13 +614,15 @@ int transport_write(rdpTransport* transport, wStream* s)
                                if (BIO_wait_write(transport->frontBio, 100) < 0)
                                {
                                        WLog_ERR(TAG, "error when selecting for write");
-                                       return -1;
+                                       status = -1;
+                                       goto out_cleanup;
                                }
 
                                if (BIO_flush(transport->frontBio) < 1)
                                {
                                        WLog_ERR(TAG, "error when flushing outputBuffer");
-                                       return -1;
+                                       status = -1;
+                                       goto out_cleanup;
                                }
                        }
                }
@@ -628,6 +631,7 @@ int transport_write(rdpTransport* transport, wStream* s)
                Stream_Seek(s, status);
        }
 
+out_cleanup:
        if (status < 0)
        {
                /* A write error indicates that the peer has dropped the connection */