aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-05-01 17:09:39 +0100
committerJonathan Wakely <jwakely@redhat.com>2024-05-07 14:47:50 +0100
commit3f04f3939ea0ac8fdd766a60655d29de2ffb44e5 (patch)
tree856fae585d047190c21b1d1a08db89a23758561e /gcc
parent9927059bb88e966e0a45f09e4fd1193f93df708f (diff)
downloadgcc-3f04f3939ea0ac8fdd766a60655d29de2ffb44e5.zip
gcc-3f04f3939ea0ac8fdd766a60655d29de2ffb44e5.tar.gz
gcc-3f04f3939ea0ac8fdd766a60655d29de2ffb44e5.tar.bz2
libstdc++: Fix handling of incomplete UTF-8 sequences in _Unicode_view
Eddie Nolan reported to me that _Unicode_view was not correctly implementing the substitution of ill-formed subsequences with U+FFFD, due to failing to increment the counter when the iterator reaches the end of the sequence before a multibyte sequence is complete. As a result, the incomplete sequence was not completely consumed, and then the remaining character was treated as another ill-formed sequence, giving two U+FFFD characters instead of one. To avoid similar mistakes in future, this change introduces a lambda that increments the iterator and the counter together. This ensures the counter is always incremented when the iterator is incremented, so that we always know how many characters have been consumed. libstdc++-v3/ChangeLog: * include/bits/unicode.h (_Unicode_view::_M_read_utf8): Ensure count of characters consumed is correct when the end of the input is reached unexpectedly. * testsuite/ext/unicode/view.cc: Test incomplete UTF-8 sequences.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions