summaryrefslogtreecommitdiffstats
path: root/libutils/String16.cpp
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-07-20 20:01:33 +0100
committerSergio Giro <sgiro@google.com>2016-08-02 18:47:53 +0000
commit1dcc0c82394ec9cd6887c7ca39f9b5024db01ac9 (patch)
tree5e07e40ae8bc52895b05b42e9d627c4f3057a0e0 /libutils/String16.cpp
parentde717d55c7a3f7d8051222f26ef12eb38b3777f2 (diff)
downloadsystem_core-1dcc0c82394ec9cd6887c7ca39f9b5024db01ac9.tar.gz
system_core-1dcc0c82394ec9cd6887c7ca39f9b5024db01ac9.tar.bz2
system_core-1dcc0c82394ec9cd6887c7ca39f9b5024db01ac9.zip
Unicode: specify destination length in utf8_to_utf16 methods
String16(const char *utf8) now returns the empty string in case a string ends halfway throw a utf8 character. Bug: 29267949 Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
Diffstat (limited to 'libutils/String16.cpp')
-rw-r--r--libutils/String16.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libutils/String16.cpp b/libutils/String16.cpp
index ac12d8aa7..9f5cfeab4 100644
--- a/libutils/String16.cpp
+++ b/libutils/String16.cpp
@@ -71,7 +71,7 @@ static char16_t* allocFromUTF8(const char* u8str, size_t u8len)
u8cur = (const uint8_t*) u8str;
char16_t* u16str = (char16_t*)buf->data();
- utf8_to_utf16(u8cur, u8len, u16str);
+ utf8_to_utf16(u8cur, u8len, u16str, ((size_t) u16len) + 1);
//printf("Created UTF-16 string from UTF-8 \"%s\":", in);
//printHexData(1, str, buf->size(), 16, 1);