summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/enumerator/enumerator.c13
-rw-r--r--ext/socket/socket.c2
2 files changed, 7 insertions, 8 deletions
diff --git a/ext/enumerator/enumerator.c b/ext/enumerator/enumerator.c
index 6e47330cefb..74785569e78 100644
--- a/ext/enumerator/enumerator.c
+++ b/ext/enumerator/enumerator.c
@@ -87,15 +87,13 @@ each_cons_i(val, memo)
{
VALUE ary = memo->u1.value;
long size = memo->u3.cnt;
- long len = RARRAY(ary)->len;
- if (len == size) {
+ if (RARRAY(ary)->len == size) {
rb_ary_shift(ary);
- rb_ary_push(ary, val);
- rb_yield(ary);
- } else {
- rb_ary_push(ary, val);
- if (len + 1 == size) rb_yield(ary);
+ }
+ rb_ary_push(ary, val);
+ if (RARRAY(ary)->len == size) {
+ rb_yield(rb_ary_dup(ary));
}
return Qnil;
}
@@ -106,7 +104,6 @@ enum_each_cons(obj, n)
{
long size = NUM2LONG(n);
NODE *memo;
- VALUE ary;
if (size <= 0) rb_raise(rb_eArgError, "invalid size");
memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 624ea9f2a6a..1df7cb988c2 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -436,10 +436,12 @@ s_recvfrom(sock, argc, argv, from)
str = rb_tainted_str_new(0, buflen);
retry:
+ rb_str_locktmp(str);
rb_thread_wait_fd(fd);
TRAP_BEG;
slen = recvfrom(fd, RSTRING(str)->ptr, buflen, flags, (struct sockaddr*)buf, &alen);
TRAP_END;
+ rb_str_unlocktmp(str);
if (slen < 0) {
if (rb_io_wait_readable(fd)) {