diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-01-19 03:08:06 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-01-19 03:15:39 +0000 |
commit | 1707419f13b206fdd9d4654b03cc34d977fdedc6 (patch) | |
tree | 7ba397590fd1242bb91dbf440abe809b9e088d52 | |
parent | d5dc32f3b3dd2577eb473bb8ec6c1b7533b5081e (diff) | |
download | ruby_io_splice-1707419f13b206fdd9d4654b03cc34d977fdedc6.tar.gz |
Newer GCC more aggressively optimizes stack allocations away, so we need to avoid passing out-of-scope addresses to vmsplice. Not that vmsplice is useful in Ruby...
-rw-r--r-- | ext/io_splice/io_splice_ext.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c index 32de838..876d07d 100644 --- a/ext/io_splice/io_splice_ext.c +++ b/ext/io_splice/io_splice_ext.c @@ -492,19 +492,18 @@ static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self) ssize_t rv = 0; ssize_t left; struct vmsplice_args a; + struct iovec iov; + VALUE io, data, flags; rb_scan_args(argc, argv, "21", &io, &data, &flags); switch (TYPE(data)) { - case T_STRING: { - struct iovec iov; - + case T_STRING: iov.iov_base = RSTRING_PTR(data); iov.iov_len = (size_t)(left = (ssize_t)RSTRING_LEN(data)); a.iov = &iov; a.nr_segs = 1; - } break; case T_ARRAY: ARY2IOVEC(a.iov, a.nr_segs, left, data); |