summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrond Norbye <trond.norbye@gmail.com>2012-10-17 11:06:06 +0200
committerdormando <dormando@rydia.net>2013-12-08 18:24:12 -0800
commit6af1d265398d6d5f698b1a714abe41af310fcae1 (patch)
treeaf1bfb5a771cb24932a26c13bd6b58575375c1c5
parent39834e15706ed931a9d7c66c78922fea56702f73 (diff)
downloadmemcached-6af1d265398d6d5f698b1a714abe41af310fcae1.tar.gz
Issue 294: Check for allocation failure
-rw-r--r--thread.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index f83dde3..2295752 100644
--- a/thread.c
+++ b/thread.c
@@ -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;