allow NULL in writeString/readString

BUG=skia:1469, code.google.com/p/android/issues/detail?id=58257
R=scroggo@google.com

Author: mtklein@google.com

Review URL: https://chromiumcodereview.appspot.com/22359003

git-svn-id: http://skia.googlecode.com/svn/trunk@10662 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp
index 56edd19..e41e2df 100644
--- a/src/core/SkWriter32.cpp
+++ b/src/core/SkWriter32.cpp
@@ -246,6 +246,12 @@
 
 const char* SkReader32::readString(size_t* outLen) {
     size_t len = this->readInt();
+    if (0xFFFF == len) {
+        if (outLen) {
+            *outLen = 0;
+        }
+        return NULL;
+    }
     const void* ptr = this->peek();
 
     // skip over teh string + '\0' and then pad to a multiple of 4
@@ -268,8 +274,12 @@
 }
 
 void SkWriter32::writeString(const char str[], size_t len) {
+    if (NULL == str) {
+        // We're already requiring len < 0xFFFF, so we can use that to mark NULL.
+        this->write32(0xFFFF);
+        return;
+    }
     if ((long)len < 0) {
-        SkASSERT(str);
         len = strlen(str);
     }
     this->write32(len);