THRIFT-4189 Framed/buffered transport Dispose() does not dispose the nested transport
Client: C#
Patch: Jens Geyer
diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs
index caedd87..c969419 100644
--- a/lib/csharp/src/Transport/TBufferedTransport.cs
+++ b/lib/csharp/src/Transport/TBufferedTransport.cs
@@ -154,8 +154,12 @@
             {
                 if (disposing)
                 {
-                    inputBuffer.Dispose();
-                    outputBuffer.Dispose();
+                    if(inputBuffer != null)
+                        inputBuffer.Dispose();
+                    if(outputBuffer != null)
+                        outputBuffer.Dispose();
+                    if(transport != null)
+                        transport.Dispose();
                 }
             }
             _IsDisposed = true;
diff --git a/lib/csharp/src/Transport/TFramedTransport.cs b/lib/csharp/src/Transport/TFramedTransport.cs
index a369e8e..0af8b1f 100644
--- a/lib/csharp/src/Transport/TFramedTransport.cs
+++ b/lib/csharp/src/Transport/TFramedTransport.cs
@@ -171,8 +171,12 @@
             {
                 if (disposing)
                 {
-                    readBuffer.Dispose();
-                    writeBuffer.Dispose();
+                    if(readBuffer != null)
+                        readBuffer.Dispose();
+                    if(writeBuffer != null)
+                        writeBuffer.Dispose();
+                    if(transport != null)
+                        transport.Dispose();
                 }
             }
             _IsDisposed = true;