1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/socket/raddrinfo.c (numeric_getaddrinfo): Use xcalloc.

Suggested by Eric Wong.
  https://bugs.ruby-lang.org/issues/9525#note-14



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-02-20 13:22:44 +00:00
parent 13834fb3cb
commit 81dfa8b397
2 changed files with 8 additions and 4 deletions

View file

@ -1,3 +1,9 @@
Thu Feb 20 22:21:26 2014 Tanaka Akira <akr@fsij.org>
* 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@gmail.com>
* hash.c (rb_hash_flatten): fix behavior of flatten(-1).

View file

@ -203,9 +203,8 @@ numeric_getaddrinfo(const char *node, const char *service,
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, const char *service,
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);