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

ruby-changes:32984

From: akr <ko1@a...>
Date: Thu, 20 Feb 2014 22:22:49 +0900 (JST)
Subject: [ruby-changes:32984] akr:r45063 (trunk): * ext/socket/raddrinfo.c (numeric_getaddrinfo): Use xcalloc.

akr	2014-02-20 22:22:44 +0900 (Thu, 20 Feb 2014)

  New Revision: 45063

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

  Log:
    * ext/socket/raddrinfo.c (numeric_getaddrinfo): Use xcalloc.
      Suggested by Eric Wong.
      https://bugs.ruby-lang.org/issues/9525#note-14

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/raddrinfo.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45062)
+++ ChangeLog	(revision 45063)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Feb 20 22:21:26 2014  Tanaka Akira  <akr@f...>
+
+	* ext/socket/raddrinfo.c (numeric_getaddrinfo): Use xcalloc.
+	  Suggested by Eric Wong.
+	  https://bugs.ruby-lang.org/issues/9525#note-14
+
 Thu Feb 20 11:21:13 2014  Masaki Matsushita  <glass.saga@g...>
 
 	* hash.c (rb_hash_flatten): fix behavior of flatten(-1).
Index: ext/socket/raddrinfo.c
===================================================================
--- ext/socket/raddrinfo.c	(revision 45062)
+++ ext/socket/raddrinfo.c	(revision 45063)
@@ -203,9 +203,8 @@ numeric_getaddrinfo(const char *node, co https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L203
             for (i = numberof(list)-1; 0 <= i; i--) {
                 if ((hint_socktype == 0 || hint_socktype == list[i].socktype) &&
                     (hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) {
-                    struct addrinfo *ai0 = xmalloc(sizeof(struct addrinfo));
+                    struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo));
                     struct sockaddr_in6 *sa = xmalloc(sizeof(struct sockaddr_in6));
-                    MEMZERO(ai0, sizeof(struct addrinfo), 1);
                     INIT_SOCKADDR_IN6(sa, sizeof(struct sockaddr_in6));
                     memcpy(&sa->sin6_addr, ipv6addr, sizeof(ipv6addr));
                     sa->sin6_port = htons(port);
@@ -229,9 +228,8 @@ numeric_getaddrinfo(const char *node, co https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L228
             for (i = numberof(list)-1; 0 <= i; i--) {
                 if ((hint_socktype == 0 || hint_socktype == list[i].socktype) &&
                     (hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) {
-                    struct addrinfo *ai0 = xmalloc(sizeof(struct addrinfo));
+                    struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo));
                     struct sockaddr_in *sa = xmalloc(sizeof(struct sockaddr_in));
-                    MEMZERO(ai0, sizeof(struct addrinfo), 1);
                     INIT_SOCKADDR_IN(sa, sizeof(struct sockaddr_in));
                     memcpy(&sa->sin_addr, ipv4addr, sizeof(ipv4addr));
                     sa->sin_port = htons(port);

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

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