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));
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to