Skip to content

Commit

Permalink
Handle case where write result is zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 13, 2022
1 parent d9ccb6b commit 425a461
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions io.c
Expand Up @@ -1620,6 +1620,12 @@ io_binwrite_string(VALUE arg)
// Write as much as possible:
ssize_t result = io_binwrite_string_internal(p->fptr, ptr, remaining);

// If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
// should try again.
if (result == 0) {
errno = EWOULDBLOCK;
}

if (result > 0) {
if ((size_t)result == remaining) break;
ptr += result;
Expand Down

0 comments on commit 425a461

Please sign in to comment.