diff options
author | Sergio Giro <sgiro@google.com> | 2016-06-28 18:26:10 +0100 |
---|---|---|
committer | Sergio Giro <sgiro@google.com> | 2016-07-02 17:46:20 +0100 |
commit | 4781057e78f63e0e99af109cebf3b6a78f4bfbb6 (patch) | |
tree | 335738441e68edc71daabc00214df505f6d45c04 /tools/aapt2/util/Util.cpp | |
parent | 4b736ea56d5301381838c80b2333a05df1eb499e (diff) |
Add bound checks to utf16_to_utf8
Test: ran libaapt2_tests64
Bug: 29250543
Change-Id: I1ebc017af623b6514cf0c493e8cd8e1d59ea26c3
Diffstat (limited to 'tools/aapt2/util/Util.cpp')
-rw-r--r-- | tools/aapt2/util/Util.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/aapt2/util/Util.cpp b/tools/aapt2/util/Util.cpp index 7b0c71d93bb5..5a87c334c59e 100644 --- a/tools/aapt2/util/Util.cpp +++ b/tools/aapt2/util/Util.cpp @@ -441,8 +441,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; } |