Date: Sat, 11 Feb 2012 04:12:12 +0000 (UTC) From: David Xu <davidxu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r231503 - head/lib/libthr/thread Message-ID: <201202110412.q1B4CCYf012555@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidxu Date: Sat Feb 11 04:12:12 2012 New Revision: 231503 URL: http://svn.freebsd.org/changeset/base/231503 Log: Make code more stable by checking NULL pointers. Modified: head/lib/libthr/thread/thr_list.c Modified: head/lib/libthr/thread/thr_list.c ============================================================================== --- head/lib/libthr/thread/thr_list.c Sat Feb 11 01:17:27 2012 (r231502) +++ head/lib/libthr/thread/thr_list.c Sat Feb 11 04:12:12 2012 (r231503) @@ -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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202110412.q1B4CCYf012555>