Unicode: specify destination length in utf8_to_utf16 methods
Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
diff --git a/tools/aapt2/util/Util.cpp b/tools/aapt2/util/Util.cpp
index 7b0c71d..7ee6e77 100644
--- a/tools/aapt2/util/Util.cpp
+++ b/tools/aapt2/util/Util.cpp
@@ -430,7 +430,11 @@
std::u16string utf16;
utf16.resize(utf16Length);
- utf8_to_utf16(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length(), &*utf16.begin());
+ utf8_to_utf16(
+ reinterpret_cast<const uint8_t*>(utf8.data()),
+ utf8.length(),
+ &*utf16.begin(),
+ (size_t) utf16Length + 1);
return utf16;
}