am d34f4198: Merge "strdup16to8.c: fix benign integer underflow."
* commit 'd34f419826e74640dfe88c50d171a0cd8580eeda':
strdup16to8.c: fix benign integer underflow.
diff --git a/libcutils/strdup16to8.c b/libcutils/strdup16to8.c
index 1a8ba86..4dc987e 100644
--- a/libcutils/strdup16to8.c
+++ b/libcutils/strdup16to8.c
@@ -55,7 +55,8 @@
/* Fast path for the usual case where 3*len is < SIZE_MAX-1.
*/
if (len < (SIZE_MAX-1)/3) {
- while (len--) {
+ while (len != 0) {
+ len--;
unsigned int uic = *utf16Str++;
if (uic > 0x07ff)
@@ -69,7 +70,8 @@
}
/* The slower but paranoid version */
- while (len--) {
+ while (len != 0) {
+ len--;
unsigned int uic = *utf16Str++;
size_t utf8Cur = utf8Len;
@@ -112,7 +114,8 @@
* strnlen16to8() properly or at a minimum checked the result of
* its malloc(SIZE_MAX) in case of overflow.
*/
- while (len--) {
+ while (len != 0) {
+ len--;
unsigned int uic = *utf16Str++;
if (uic > 0x07ff) {