Bypass asserts in string [] operator for empty strings

The previous behaviour of [] on an empty string was to return 0
regardless of the index. We wanted to make this more strict, hence the
current behaviour. This has led to a number of crashes due to code
depending on the old behaviour. Reverting to the old behaviour until
we have time to correct the call sites using empty strings.

Bug=chromium:752480, pdfium:828

Change-Id: I511eea4148de85bf7f4694351e7a030b1a37f0de
Reviewed-on: https://pdfium-review.googlesource.com/11630
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h
index 3e8b661..0e8e006 100644
--- a/core/fxcrt/cfx_bytestring.h
+++ b/core/fxcrt/cfx_bytestring.h
@@ -107,9 +107,9 @@
   const CFX_ByteString& operator+=(const CFX_ByteString& str);
   const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc);
 
-  const CharType& operator[](const FX_STRSIZE index) const {
+  CharType operator[](const FX_STRSIZE index) const {
     ASSERT(index >= 0 && index < GetLength());
-    return m_pData->m_String[index];
+    return m_pData ? m_pData->m_String[index] : 0;
   }
 
   void SetAt(FX_STRSIZE index, char c);
diff --git a/core/fxcrt/cfx_widestring.h b/core/fxcrt/cfx_widestring.h
index d57e47c..f9e800d 100644
--- a/core/fxcrt/cfx_widestring.h
+++ b/core/fxcrt/cfx_widestring.h
@@ -101,9 +101,9 @@
 
   bool operator<(const CFX_WideString& str) const;
 
-  const CharType& operator[](const FX_STRSIZE index) const {
+  CharType operator[](const FX_STRSIZE index) const {
     ASSERT(index >= 0 && index < GetLength());
-    return m_pData->m_String[index];
+    return m_pData ? m_pData->m_String[index] : 0;
   }
 
   void SetAt(FX_STRSIZE index, wchar_t c);