Don't process surrogate pair chars
authorDenis Kenzior <denkenz@gmail.com>
Tue, 7 Jul 2009 18:50:09 +0000 (13:50 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 7 Jul 2009 19:33:59 +0000 (14:33 -0500)
These are not valid UCS2 chars

src/util.c

index 91116d0..e817730 100644 (file)
@@ -765,6 +765,10 @@ char *sim_string_to_utf8(const unsigned char *buffer, int length)
 
                if (buffer[i] & 0x80) {
                        c = (buffer[i++] & 0x7f) + ucs2_offset;
+
+                       if (c >= 0xd800 && c < 0xe000)
+                               return NULL;
+
                        res_len += UTF8_LENGTH(c);
                        j += 1;
                        continue;