avoid possible dead loop for invalid utf8
Change-Id: Ida48b7ff119030312836aa109072ac4de7c5b9d6
diff --git a/minuitwrp/truetype.c b/minuitwrp/truetype.c
index a286449..8f62ff2 100644
--- a/minuitwrp/truetype.c
+++ b/minuitwrp/truetype.c
@@ -120,9 +120,6 @@
int utf8_to_unicode(unsigned char* pIn, unsigned int *pOut)
{
- if(pIn == NULL || pOut == NULL)
- return 0;
-
int utf_bytes = 1;
unsigned int unicode = 0;
unsigned char tmp;
@@ -139,7 +136,11 @@
while((tmp & 0xC0) == 0xC0)
{
utf_bytes ++;
- if(utf_bytes > 6) return 0;
+ if(utf_bytes > 6)
+ {
+ *pOut = tmp;
+ return 1;
+ }
tmp = 0xFF & (tmp << 1);
total_bits += 6;
high_bit_mask >>= 1;