summaryrefslogtreecommitdiff
path: root/ext/socket/ancdata.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-05 08:28:14 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-05 08:28:14 +0000
commit7ac8fe74074a085eb79dfbf501f186fe0af7d1b2 (patch)
tree8e44ce79615dd7c7dd2c2b0fb08341bd46d56c46 /ext/socket/ancdata.c
parent20dedbfd9d56a66aa97d4aca2ec0b732eaf7741f (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/ancdata.c')
-rw-r--r--ext/socket/ancdata.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index ff17deb..ea55534 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1134,6 +1134,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
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 *argv, VALUE sock, int nonblock)
#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__)