diff --git a/ChangeLog b/ChangeLog index 338da25b04..8a43f6fe95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jun 5 17:27:30 2015 Eric Wong + + * 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 * ext/socket/ancdata.c (bsock_sendmsg_internal): fix build error diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index ff17deb2b3..ea55534d97 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__)