Skip to content

Commit

Permalink
[BUGFIX] Fix issue parrot#942
Browse files Browse the repository at this point in the history
io_readline_encoded_string() used to wait for max_bytes_per_codepoint
bytes, which is 4 in case of UTF-8.

However, as UTF-8 is variable-length, there's no guarantee that we'll actually
receive that many bytes and we might hang until the stream gets closed.
  • Loading branch information
gerdr committed Mar 10, 2013
1 parent 83bb863 commit 2dcc1f4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/io/utilities.c
Expand Up @@ -421,7 +421,10 @@ io_readline_encoded_string(PARROT_INTERP, ARGMOD(PMC *handle),
if (encoding == NULL)
encoding = io_get_encoding(interp, handle, vtable, PIO_F_READ);

if (available_bytes < delim_size || available_bytes < encoding->max_bytes_per_codepoint)
/* FIXME: available_bytes < delim_size only makes sense if the
encodings agree
*/
if (available_bytes < delim_size || available_bytes < encoding->bytes_per_unit)
available_bytes = Parrot_io_buffer_fill(interp, buffer, handle, vtable);

s->encoding = encoding;
Expand Down

0 comments on commit 2dcc1f4

Please sign in to comment.