Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed detection of overlong sequences (thanks Tommy!)

  • Loading branch information
slouken committed Jul 6, 2013
1 parent f27179a commit a3c9043db7f8ce0a7cd7514a4adbb1496d215af3
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/stdlib/SDL_iconv.c
@@ -364,7 +364,7 @@ SDL_iconv(SDL_iconv_t cd,
*/
ch = UNKNOWN_UNICODE;
} else {
if (p[0] == 0xFC) {
if (p[0] == 0xFC && srclen > 1 && (p[1] & 0xFC) == 0x80) {
overlong = SDL_TRUE;
}
ch = (Uint32) (p[0] & 0x01);
@@ -377,7 +377,7 @@ SDL_iconv(SDL_iconv_t cd,
*/
ch = UNKNOWN_UNICODE;
} else {
if (p[0] == 0xF8) {
if (p[0] == 0xF8 && srclen > 1 && (p[1] & 0xF8) == 0x80) {
overlong = SDL_TRUE;
}
ch = (Uint32) (p[0] & 0x03);
@@ -390,7 +390,7 @@ SDL_iconv(SDL_iconv_t cd,
*/
ch = UNKNOWN_UNICODE;
} else {
if (p[0] == 0xF0) {
if (p[0] == 0xF0 && srclen > 1 && (p[1] & 0xF0) == 0x80) {
overlong = SDL_TRUE;
}
ch = (Uint32) (p[0] & 0x07);
@@ -403,7 +403,7 @@ SDL_iconv(SDL_iconv_t cd,
*/
ch = UNKNOWN_UNICODE;
} else {
if (p[0] == 0xE0) {
if (p[0] == 0xE0 && srclen > 1 && (p[1] & 0xE0) == 0x80) {
overlong = SDL_TRUE;
}
ch = (Uint32) (p[0] & 0x0F);

0 comments on commit a3c9043

Please sign in to comment.