Merging latest minor Cocoa changes

Summary: BinaryProtocol handling of null strings, destructor, and contributors email fix. Submitted by Andrew McGeachie

Reviewed By: mcslee


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665278 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cocoa/TBinaryProtocol.m b/lib/cocoa/TBinaryProtocol.m
index 2d2ca8e..ba7808c 100644
--- a/lib/cocoa/TBinaryProtocol.m
+++ b/lib/cocoa/TBinaryProtocol.m
@@ -24,6 +24,13 @@
 }
 
 
+- (void) dealloc
+{
+  [mTransport release];
+  [super dealloc];
+}
+
+
 - (id <TTransport>) transport
 {
   return mTransport;
@@ -332,12 +339,18 @@
   [self writeI64: *((int64_t *) &value)];
 }
 
+
 - (void) writeString: (NSString *) value
 {
-  const char * utf8Bytes = [value UTF8String];
-  size_t length = strlen(utf8Bytes);
-  [self writeI32: length];
-  [mTransport write: (uint8_t *) utf8Bytes offset: 0 length: length];
+  if (value != nil) {
+    const char * utf8Bytes = [value UTF8String];
+    size_t length = strlen(utf8Bytes);
+    [self writeI32: length];
+    [mTransport write: (uint8_t *) utf8Bytes offset: 0 length: length];
+  } else {
+    // instead of crashing when we get null, let's write out a zero length string
+    [self writeI32: 0];
+  }
 }