summaryrefslogtreecommitdiffstats
path: root/tools/aapt2
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-06-28 18:26:10 +0100
committergitbuildkicker <android-build@google.com>2016-07-21 17:34:52 -0700
commitf0ea4c8737ec911074cc4d284f984c5c353f32e2 (patch)
tree0f19f2d541dca7380ba3a90057ecc4f6c952f59e /tools/aapt2
parent28460c294ebd9c9cab258c92a20e0e2cc63e64f0 (diff)
downloadframeworks_base-f0ea4c8737ec911074cc4d284f984c5c353f32e2.zip
frameworks_base-f0ea4c8737ec911074cc4d284f984c5c353f32e2.tar.gz
frameworks_base-f0ea4c8737ec911074cc4d284f984c5c353f32e2.tar.bz2
Add bound checks to utf16_to_utf8
Test: ran libaapt2_tests64 Bug: 29250543 Change-Id: I1ebc017af623b6514cf0c493e8cd8e1d59ea26c3 (cherry picked from commit 4781057e78f63e0e99af109cebf3b6a78f4bfbb6)
Diffstat (limited to 'tools/aapt2')
-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 03ecd1a..5b064e3 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;
}