summaryrefslogtreecommitdiff
path: root/tools/aapt2/StringPool.cpp
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2016-01-14 02:51:02 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-01-14 02:51:02 +0000
commit44859db74bb1cc2341524c5484cc3e765ec42c42 (patch)
tree2ee50fa0fb92410de8867e7eec342e1e303ba54c /tools/aapt2/StringPool.cpp
parente7d716d5e35a4e6b5fcc1ff012942e4ad4933d1a (diff)
parent52364f7ae31716d7827ea8f8566f4a28bd30a921 (diff)
Merge "AAPT2: Variety of small fixes to get the build working"
Diffstat (limited to 'tools/aapt2/StringPool.cpp')
-rw-r--r--tools/aapt2/StringPool.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/aapt2/StringPool.cpp b/tools/aapt2/StringPool.cpp
index 8552f470b123..aadb00b6be2a 100644
--- a/tools/aapt2/StringPool.cpp
+++ b/tools/aapt2/StringPool.cpp
@@ -14,9 +14,9 @@
* limitations under the License.
*/
+#include "StringPool.h"
#include "util/BigBuffer.h"
#include "util/StringPiece.h"
-#include "StringPool.h"
#include "util/Util.h"
#include <algorithm>
@@ -342,7 +342,14 @@ bool StringPool::flatten(BigBuffer* out, const StringPool& pool, bool utf8) {
// Encode the actual UTF16 string length.
data = encodeLength(data, entry->value.size());
- strncpy16(data, entry->value.data(), entry->value.size());
+ const size_t byteLength = entry->value.size() * sizeof(char16_t);
+
+ // NOTE: For some reason, strncpy16(data, entry->value.data(), entry->value.size())
+ // truncates the string.
+ memcpy(data, entry->value.data(), byteLength);
+
+ // The null-terminating character is already here due to the block of data being set
+ // to 0s on allocation.
}
}