summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-16 05:06:16 +0000
committerwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-16 05:06:16 +0000
commit98cf9c43fa18bf0874af47b9d1b4933981ea456d (patch)
tree3124c627df5d9c73e767e9c43df29c20dae042f7 /io.c
parentca7b32630c7c884fb057916e488a146476768f37 (diff)
* io.c (read_all): shift read buffer if exception occured.
pointed out in [ruby-dev:39702]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/io.c b/io.c
index 5479b9c0f0..17ee292f5b 100644
--- a/io.c
+++ b/io.c
@@ -1686,13 +1686,20 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
else rb_str_set_len(str, 0);
make_readconv(fptr, 0);
while (1) {
+ int fin, state = 0;
+
if (fptr->cbuf_len > fptr->cbuf_capa / 2) {
io_shift_cbuf(fptr, fptr->cbuf_len, &str);
}
- if (more_char(fptr) == -1) {
+
+ fin = rb_protect((VALUE (*)(VALUE))more_char, (VALUE)fptr, &state);
+ if (fin == -1 || state != 0) {
if (fptr->cbuf_len) {
io_shift_cbuf(fptr, fptr->cbuf_len, &str);
}
+ if (state != 0) {
+ rb_jump_tag(state);
+ }
clear_readconv(fptr);
return io_enc_str(str, fptr);
}