Merge "Fail explicitly on length overflow." into qt-qpr1-dev
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;
     }