summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/io.c b/io.c
index 28cb8a51c75..90338e6f2ae 100644
--- a/io.c
+++ b/io.c
@@ -2451,7 +2451,8 @@ rb_io_puts(argc, argv, out)
line = rb_obj_as_string(argv[i]);
}
rb_io_write(out, line);
- if (RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') {
+ if (RSTRING(line)->len == 0 ||
+ RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') {
rb_io_write(out, rb_default_rs);
}
}