summaryrefslogtreecommitdiff
path: root/tools/aapt2/Util.cpp
diff options
context:
space:
mode:
author Sergio Giro <sgiro@google.com> 2016-07-14 18:23:54 +0000
committer android-build-merger <android-build-merger@google.com> 2016-07-14 18:23:54 +0000
commitff58d7c918d4923f6df44f55d21d62bcaf7068f6 (patch)
tree53e95b0ae5c15d4e2f1f3e5fa425301535fe0045 /tools/aapt2/Util.cpp
parentcbe258aa2792ebf353f69bfd5770e678e51a7100 (diff)
parentbab33342263865e80575f8ac9adf4196ca771dc5 (diff)
Add bound checks to utf16_to_utf8 am: bce11021b2 am: 008120497b
am: bab3334226 Change-Id: I6e4e399dfcf89f46d40a162c77462b889883f569
Diffstat (limited to 'tools/aapt2/Util.cpp')
-rw-r--r--tools/aapt2/Util.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/aapt2/Util.cpp b/tools/aapt2/Util.cpp
index 03ecd1aca310..5b064e33d162 100644
--- a/tools/aapt2/Util.cpp
+++ b/tools/aapt2/Util.cpp
@@ -303,8 +303,10 @@ std::string utf16ToUtf8(const StringPiece16& utf16) {
}
std::string utf8;
+ // Make room for '\0' explicitly.
+ utf8.resize(utf8Length + 1);
+ utf16_to_utf8(utf16.data(), utf16.length(), &*utf8.begin(), utf8Length + 1);
utf8.resize(utf8Length);
- utf16_to_utf8(utf16.data(), utf16.length(), &*utf8.begin());
return utf8;
}