Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72299bf0 authored by Cylen Yao's avatar Cylen Yao Committed by Raph Levien
Browse files

[Bug]NE when playing mp3 with incorrect UTF16 char

Bug: 15274351
Bug: 15539240

Many MP3 files have incorrect utf16 chars, but the
Utf16_to_utf8_length() routine checks for errors in
standard utf16 char.  utf16_to_utf8() was not checking
for errors in standard utf16 char.

Change-Id: Iafd922ff92cabe6bba8971215fcfd1fd471c894b
(cherry picked from commit 605b139cdf56364c6c9b37e59dd12efc61c24631)
parent c24b98c7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -342,7 +342,8 @@ void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst)
    while (cur_utf16 < end_utf16) {
        char32_t utf32;
        // surrogate pairs
        if ((*cur_utf16 & 0xFC00) == 0xD800) {
        if((*cur_utf16 & 0xFC00) == 0xD800 && (cur_utf16 + 1) < end_utf16
                && (*(cur_utf16 + 1) & 0xFC00) == 0xDC00) {
            utf32 = (*cur_utf16++ - 0xD800) << 10;
            utf32 |= *cur_utf16++ - 0xDC00;
            utf32 += 0x10000;