diff options
author | Sergio Giro <sgiro@google.com> | 2016-07-12 01:46:30 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-07-12 01:46:30 +0000 |
commit | fb5cfc3543e7905476f3602b854f8458d7927422 (patch) | |
tree | c455f691258cbd6f9428da62f72eb28df31ef1a3 /tools/aapt2/util/Util.cpp | |
parent | 177c82be7931a5b4df9fe019462bfe24e49864f6 (diff) | |
parent | daad138428b6b38c23f3412f3531e9edad617ef6 (diff) |
Merge \\"Add bound checks to utf16_to_utf8\\" into nyc-mr1-dev am: 49c410bc48
am: daad138428
Change-Id: I5a660dccb76e823736a59e50904a7279a97ef849
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 5748a1269072..c41eb05e45bb 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; } |