From 83f1241ad5a791df2c2dfbf0be3a316e37c70c67 Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 1 Jul 2010 07:41:55 +0000 Subject: [PATCH] merges r28457 from trunk into ruby_1_9_2. -- * thread.c (rb_fd_resize, rb_fd_copy): avoid NULL dereference upon failed realloc by using xrealloc instead of not realloc. a patch from Jim Meyering in [ruby-core:30920] [Bug #3489] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ thread.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6bc4917129..bec7bcb17a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 28 21:56:14 2010 Yusuke Endoh + + * thread.c (rb_fd_resize, rb_fd_copy): avoid NULL dereference upon + failed realloc by using xrealloc instead of not realloc. a patch + from Jim Meyering in [ruby-core:30920] + [Bug #3489] + Thu Jul 1 16:26:42 2010 NARUSE, Yui * thread_pthread.c (thread_start_func_1): don't call diff --git a/thread.c b/thread.c index 0b36f15bcb..aa6ecede07 100644 --- a/thread.c +++ b/thread.c @@ -2285,7 +2285,7 @@ rb_fd_resize(int n, rb_fdset_t *fds) if (o < sizeof(fd_set)) o = sizeof(fd_set); if (m > o) { - fds->fdset = realloc(fds->fdset, m); + fds->fdset = xrealloc(fds->fdset, m); memset((char *)fds->fdset + o, 0, m - o); } if (n >= fds->maxfd) fds->maxfd = n + 1; @@ -2319,7 +2319,7 @@ rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int max) if (size < sizeof(fd_set)) size = sizeof(fd_set); dst->maxfd = max; - dst->fdset = realloc(dst->fdset, size); + dst->fdset = xrealloc(dst->fdset, size); memcpy(dst->fdset, src, size); }