summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sergio Giro <sgiro@google.com> 2016-07-21 14:46:35 +0100
committer Martijn Coenen <maco@google.com> 2016-08-25 12:01:39 +0200
commite1d310d75c0993e430ed192c7b862d287766d6af (patch)
tree1e6511d12a8e1484f7f44698b228cf60da9fce53
parentd1b0747e164a851a46a82ba531d9061967fe6d26 (diff)
Unicode: specify destination length in utf8_to_utf16 methods
Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
-rw-r--r--libs/binder/Parcel.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index e53a5519a7..244da2761f 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -784,7 +784,7 @@ status_t Parcel::writeUtf8AsUtf16(const std::string& str) {
const uint8_t* strData = (uint8_t*)str.data();
const size_t strLen= str.length();
const ssize_t utf16Len = utf8_to_utf16_length(strData, strLen);
- if (utf16Len < 0 || utf16Len> std::numeric_limits<int32_t>::max()) {
+ if (utf16Len < 0 || utf16Len > std::numeric_limits<int32_t>::max()) {
return BAD_VALUE;
}
@@ -799,7 +799,7 @@ status_t Parcel::writeUtf8AsUtf16(const std::string& str) {
return NO_MEMORY;
}
- utf8_to_utf16(strData, strLen, (char16_t*)dst);
+ utf8_to_utf16(strData, strLen, (char16_t*)dst, (size_t) utf16Len + 1);
return NO_ERROR;
}