From fdbc565dd5a4ce68303dc6d9eeef2f2c9387bd0f Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 13 Jul 2020 23:31:45 +0000 Subject: [PATCH] String8: explicit int -> char cast. Since tolower/toupper take and return integer arguments, ascii chars in the extended range will be converted from positive int values to negative char values. In order to silence an error here, which was added recently with integer sanitization here, casting explicitly. Fixes: 160831549 Test: w/ libutils_fuzz_string8 Change-Id: Iedcd6643f95f84ce662a80e38931d918a200f508 --- libutils/String8.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libutils/String8.cpp b/libutils/String8.cpp index d00e39c56..c83789145 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp @@ -424,7 +424,7 @@ void String8::toLower(size_t start, size_t length) char* buf = lockBuffer(len); buf += start; while (length > 0) { - *buf = tolower(*buf); + *buf = static_cast(tolower(*buf)); buf++; length--; } @@ -448,7 +448,7 @@ void String8::toUpper(size_t start, size_t length) char* buf = lockBuffer(len); buf += start; while (length > 0) { - *buf = toupper(*buf); + *buf = static_cast(toupper(*buf)); buf++; length--; }