Merge "Fail explicitly on length overflow." into oc-dev
diff --git a/libutils/String16.cpp b/libutils/String16.cpp
index e8f1c51..7055fc6 100644
--- a/libutils/String16.cpp
+++ b/libutils/String16.cpp
@@ -402,7 +402,7 @@
         mString = getEmptyString();
         return NO_ERROR;
     }
-    if ((begin+len) > N) len = N-begin;
+    if (len > N || len > N - begin) len = N - begin;
     if (begin == 0 && len == N) {
         return NO_ERROR;
     }