[前][次][番号順一覧][スレッド一覧]

ruby-changes:38700

From: normal <ko1@a...>
Date: Fri, 5 Jun 2015 17:28:34 +0900 (JST)
Subject: [ruby-changes:38700] normal:r50781 (trunk): ext/socket/ancdata.c (bsock_sendmsg_internal): portability fix

normal	2015-06-05 17:28:14 +0900 (Fri, 05 Jun 2015)

  New Revision: 50781

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50781

  Log:
    ext/socket/ancdata.c (bsock_sendmsg_internal): portability fix
    
    * ext/socket/ancdata.c (bsock_sendmsg_internal): avoid msg_control
      ptr if msg_controllen is zero to fix portability problems.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/ancdata.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50780)
+++ ChangeLog	(revision 50781)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun  5 17:27:30 2015  Eric Wong  <e@8...>
+
+	* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid msg_control
+	  ptr if msg_controllen is zero to fix portability problems.
+
 Fri Jun  5 09:17:45 2015  Eric Wong  <e@8...>
 
 	* ext/socket/ancdata.c (bsock_sendmsg_internal): fix build error
Index: ext/socket/ancdata.c
===================================================================
--- ext/socket/ancdata.c	(revision 50780)
+++ ext/socket/ancdata.c	(revision 50781)
@@ -1134,6 +1134,7 @@ bsock_sendmsg_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1134
     struct msghdr mh;
     struct iovec iov;
     VALUE controls = Qnil;
+    int controls_num;
 #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
     VALUE controls_str = 0;
     int family;
@@ -1157,11 +1158,11 @@ bsock_sendmsg_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1158
 #endif
 
     StringValue(data);
+    controls_num = RARRAY_LENINT(controls);
 
-    if (!NIL_P(controls)) {
+    if (controls_num) {
 #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
 	int i;
-	int controls_num = RARRAY_LENINT(controls);
 	size_t last_pad = 0;
 	const VALUE *controls_ptr = RARRAY_CONST_PTR(controls);
 #if defined(__NetBSD__)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]