mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 15:17:29 +00:00
Fix bounds error in utf16_to_utf8 conversion
This commit is contained in:
parent
2320714339
commit
a35d4ce9cc
@ -1955,7 +1955,7 @@ QUtil::utf16_to_utf8(std::string const& val)
|
||||
}
|
||||
// If the string has an odd number of bytes, the last byte is
|
||||
// ignored.
|
||||
for (size_t i = start; i < len; i += 2)
|
||||
for (size_t i = start; i + 1 < len; i += 2)
|
||||
{
|
||||
// Convert from UTF16-BE. If we get a malformed
|
||||
// codepoint, this code will generate incorrect output
|
||||
|
@ -53,6 +53,8 @@ HAGOOGAMAGOOGLE: 0
|
||||
0xdead -> ff fd
|
||||
0x7fffffff -> ff fd
|
||||
0x80000000 -> ff fd
|
||||
π
|
||||
π
|
||||
---- utf8_to_ascii
|
||||
¿Does π have fingers?
|
||||
?Does ? have fingers?
|
||||
|
@ -238,6 +238,10 @@ void to_utf16_test()
|
||||
print_utf16(0xdeadUL);
|
||||
print_utf16(0x7fffffffUL);
|
||||
print_utf16(0x80000000UL);
|
||||
|
||||
std::string s(QUtil::utf8_to_utf16("\xcf\x80"));
|
||||
std::cout << QUtil::utf16_to_utf8(s) << std::endl;
|
||||
std::cout << QUtil::utf16_to_utf8(s + ".") << std::endl;
|
||||
}
|
||||
|
||||
void utf8_to_ascii_test()
|
||||
|
Loading…
Reference in New Issue
Block a user