diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-03-14 15:37:03 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-03-14 15:37:03 +0100 |
commit | b51f04bf235041588cdaf7199af765710c0c3695 (patch) | |
tree | 91dac355b40d528a2e60deedf4aafcdf40ed561e /lib | |
parent | 6a353b105a9476635acbf1d9188e6ef9a6596f79 (diff) |
easy: add check to malloc() when running event-based
... to allow torture tests then too.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/easy.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/easy.c b/lib/easy.c index d529da870..f6b434aa8 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -541,14 +541,18 @@ static int events_socket(CURL *easy, /* easy handle */ } else { m = malloc(sizeof(struct socketmonitor)); - m->next = ev->list; - m->socket.fd = s; - m->socket.events = socketcb2poll(what); - m->socket.revents = 0; - ev->list = m; - infof(easy, "socket cb: socket %d ADDED as %s%s\n", s, - what&CURL_POLL_IN?"IN":"", - what&CURL_POLL_OUT?"OUT":""); + if(m) { + m->next = ev->list; + m->socket.fd = s; + m->socket.events = socketcb2poll(what); + m->socket.revents = 0; + ev->list = m; + infof(easy, "socket cb: socket %d ADDED as %s%s\n", s, + what&CURL_POLL_IN?"IN":"", + what&CURL_POLL_OUT?"OUT":""); + } + else + return CURLE_OUT_OF_MEMORY; } } |