summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/event.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-27 11:13:32 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-28 03:34:48 -0700
commit753146c0ff4b1b55892b71b36d6ca97797867aaa (patch)
tree2e449e2c30f41248c6e533d7dde7dd381166725d /libglusterfs/src/event.c
parent0aae2c46579421b871919e93619273d9a9bc79fb (diff)
some check added to the variables after GF_CALLOC
handles some NULL dereference problems (reported by clang when ran with code where '#define GF_CALLOC NULL'). Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 966 (NULL check for avoiding NULL dereferencing of pointers..) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=966
Diffstat (limited to 'libglusterfs/src/event.c')
-rw-r--r--libglusterfs/src/event.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c
index 3243e7f2320..59b1bd79eac 100644
--- a/libglusterfs/src/event.c
+++ b/libglusterfs/src/event.c
@@ -195,6 +195,8 @@ event_register_poll (struct event_pool *event_pool, int fd,
event_pool->reg = GF_REALLOC (event_pool->reg,
event_pool->count *
sizeof (*event_pool->reg));
+ if (!event_pool->reg)
+ goto unlock;
}
idx = event_pool->used++;
@@ -239,6 +241,7 @@ event_register_poll (struct event_pool *event_pool, int fd,
event_pool->changed = 1;
}
+unlock:
pthread_mutex_unlock (&event_pool->mutex);
return idx;
@@ -402,6 +405,8 @@ event_dispatch_poll_resize (struct event_pool *event_pool,
ufds = GF_CALLOC (sizeof (struct pollfd),
event_pool->evcache_size,
gf_common_mt_pollfd);
+ if (!ufds)
+ goto unlock;
event_pool->evcache = ufds;
}