String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8 am: 4e27b6992b

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: Id47901d6e4247aafb9f666ba505ab966d3adefed
diff --git a/libutils/String16.cpp b/libutils/String16.cpp
index 818b171..caab1bd 100644
--- a/libutils/String16.cpp
+++ b/libutils/String16.cpp
@@ -389,7 +389,7 @@
         mString = getEmptyString();
         return OK;
     }
-    if ((begin+len) > N) len = N-begin;
+    if (len > N || len > N - begin) len = N - begin;
     if (begin == 0 && len == N) {
         return OK;
     }