diff --git a/io.c b/io.c index cd7f0aa07f..cbca404d06 100644 --- a/io.c +++ b/io.c @@ -1960,7 +1960,7 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io) swallow(fptr, '\n'); } } - str = io_enc_str(str, fptr); + if (!NIL_P(str)) str = io_enc_str(str, fptr); } if (!NIL_P(str)) {