CHECK() valid index in {Byte,Wide}String operator[].

Because we really don't want to silently tolerate this. Binary
size appears about the same, presumably since we can remove
another branch below the check, since if the index is valid,
we know we have non-null m_pData.

Change-Id: Ic7ad01a9a8a0de4bbda3be9637814d80694f7bf0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52351
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index 1c85c05..aff96ed 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -16,6 +16,7 @@
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/string_data_template.h"
 #include "core/fxcrt/string_view_template.h"
+#include "third_party/base/logging.h"
 #include "third_party/base/optional.h"
 #include "third_party/base/span.h"
 
@@ -140,8 +141,8 @@
   const ByteString& operator+=(ByteStringView bstrc);
 
   CharType operator[](const size_t index) const {
-    ASSERT(IsValidIndex(index));
-    return m_pData ? m_pData->m_String[index] : 0;
+    CHECK(IsValidIndex(index));
+    return m_pData->m_String[index];
   }
 
   CharType First() const { return GetLength() ? (*this)[0] : 0; }
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 73c275b..15c6e8c 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -15,6 +15,7 @@
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/string_data_template.h"
 #include "core/fxcrt/string_view_template.h"
+#include "third_party/base/logging.h"
 #include "third_party/base/optional.h"
 #include "third_party/base/span.h"
 
@@ -132,8 +133,8 @@
   bool operator<(const WideString& other) const;
 
   CharType operator[](const size_t index) const {
-    ASSERT(IsValidIndex(index));
-    return m_pData ? m_pData->m_String[index] : 0;
+    CHECK(IsValidIndex(index));
+    return m_pData->m_String[index];
   }
 
   CharType First() const { return GetLength() ? (*this)[0] : 0; }