diff options
author | Trond Norbye <trond.norbye@gmail.com> | 2012-10-17 11:06:06 +0200 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2013-12-08 18:24:12 -0800 |
commit | 6af1d265398d6d5f698b1a714abe41af310fcae1 (patch) | |
tree | af1bfb5a771cb24932a26c13bd6b58575375c1c5 | |
parent | 39834e15706ed931a9d7c66c78922fea56702f73 (diff) | |
download | memcached-6af1d265398d6d5f698b1a714abe41af310fcae1.tar.gz |
Issue 294: Check for allocation failure
-rw-r--r-- | thread.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -444,6 +444,13 @@ void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport) { CQ_ITEM *item = cqi_new(); char buf[1]; + if (item == NULL) { + close(sfd); + /* given that malloc failed this may also fail, but let's try */ + fprintf(stderr, "Failed to allocate memory for connection object\n"); + return ; + } + int tid = (last_thread + 1) % settings.num_threads; LIBEVENT_THREAD *thread = threads + tid; |