io_splice RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] vmsplice: avoid referencing invalid stack address for strings
@ 2013-01-19  4:54 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2013-01-19  4:54 UTC (permalink / raw)
  To: ruby.io.splice

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...
---
 pushed to "master" of git://bogomips.org/ruby_io_splice

 ext/io_splice/io_splice_ext.c | 7 +++----
 1 file 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);
-- 
Eric Wong


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-19  4:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-19  4:54 [PATCH] vmsplice: avoid referencing invalid stack address for strings Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/ruby_io_splice.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).