Skip to content

Commit

Permalink
Merge pull request #2376 from DmitryOlshansky/issue-12923
Browse files Browse the repository at this point in the history
Fix issue 12923
  • Loading branch information
yebblies authored and AndrewEdwards committed Jul 31, 2014
1 parent 5bc1122 commit 8888970
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions std/utf.d
Expand Up @@ -1134,8 +1134,8 @@ private dchar decodeImpl(bool canIndex, S)(auto ref S str, ref size_t index)
else
return new UTFException("Attempted to decode past the end of a string");
}

assert(fst & 0x80);
if((fst & 0b1100_0000) != 0b1100_0000)
throw invalidUTF(); // starter must have at least 2 first bits set
ubyte tmp = void;
dchar d = fst; // upper control bits are masked out later
fst <<= 1;
Expand Down Expand Up @@ -2020,6 +2020,14 @@ void validate(S)(in S str) @safe pure
}


unittest // bugzilla 12923
{
assertThrown((){
char[3]a=[167, 133, 175];
validate(a[]);
}());
}

/* =================== Conversion to UTF8 ======================= */

pure
Expand Down

0 comments on commit 8888970

Please sign in to comment.