diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-02-11 04:12:12 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-02-11 04:12:12 +0000 |
commit | 508a5a2b93601f03c1e67b2967406d34fff08e7d (patch) | |
tree | 02cb7ec1c037b96225c18028fafdf7eeab10acf1 /lib/libthr/thread | |
parent | f8da975fafd830421ec1cfd6b3fb95d6847ba59d (diff) | |
download | FreeBSD-src-508a5a2b93601f03c1e67b2967406d34fff08e7d.zip FreeBSD-src-508a5a2b93601f03c1e67b2967406d34fff08e7d.tar.gz |
Make code more stable by checking NULL pointers.
Diffstat (limited to 'lib/libthr/thread')
-rw-r--r-- | lib/libthr/thread/thr_list.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c index 5a2bc63..d27d87d 100644 --- a/lib/libthr/thread/thr_list.c +++ b/lib/libthr/thread/thr_list.c @@ -154,8 +154,12 @@ _thr_alloc(struct pthread *curthread) atomic_fetchadd_int(&total_threads, -1); return (NULL); } - thread->sleepqueue = _sleepq_alloc(); - thread->wake_addr = _thr_alloc_wake_addr(); + if ((thread->sleepqueue = _sleepq_alloc()) == NULL || + (thread->wake_addr = _thr_alloc_wake_addr()) == NULL) { + thr_destroy(curthread, thread); + atomic_fetchadd_int(&total_threads, -1); + return (NULL); + } } else { bzero(&thread->_pthread_startzero, __rangeof(struct pthread, _pthread_startzero, _pthread_endzero)); |