Skip to content

Commit 081980e

Browse files
authored
fix(mojo): grow string buffer (#39)
We grow the string buffer if a string carried by the MOJO stream overfills it.
1 parent 18e0d79 commit 081980e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

austin/format/mojo.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,12 @@ def str_reader() -> t.Generator[t.Optional[str], bytes, str]:
277277
(b,) = yield bytes(buffer[:i]).decode(errors="replace")
278278
i = 0
279279
else:
280-
buffer[i] = b
280+
try:
281+
buffer[i] = b
282+
except IndexError:
283+
# Expand the buffer if needed
284+
buffer += bytearray(i - len(buffer) + 1)
285+
buffer[i] = b
281286
(b,) = yield None
282287
i += 1
283288

0 commit comments

Comments
 (0)