From 339184c378bf60085f6eef0da9cc53aa64adaf27 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 27 Jun 2010 15:59:33 +0200 Subject: [PATCH] avoid NULL dereference upon failed realloc * thread.c (rb_fd_resize): Use xrealloc, not realloc. * thread.c (rb_fd_copy): Likewise. --- thread.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/thread.c b/thread.c index c897edb..be580ac 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); } -- 1.7.1.764.g84d391