Skip to content

Commit 9b47409

Browse files
committed
pythonbuf::utf8_remainder check end iterator
1 parent 4d655b0 commit 9b47409

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/pybind11/iostream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class pythonbuf : public std::streambuf {
6666
// UTF-8 leading byte
6767
const auto rpend = rbase - rpptr >= 3 ? rpptr + 3 : rbase;
6868
const auto leading = std::find_if(rpptr, rpend, is_leading);
69+
if (leading == rbase)
70+
return 0;
6971
const auto dist = static_cast<size_t>(leading - rpptr);
7072
size_t remainder = 0;
7173

0 commit comments

Comments
 (0)