From f12a8f9703ff07160cab6341300a0818855928b2 Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Mon, 29 Aug 2005 13:49:18 +0000 Subject: [PATCH] Handle failure to malloc() part of the thread structure. PR: 83457 --- lib/libkse/thread/thr_kern.c | 7 ++++--- lib/libpthread/thread/thr_kern.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index aec254122a5..85d9b33fafa 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -2372,12 +2372,13 @@ _thr_alloc(struct pthread *curthread) } else { thread->tcb = _tcb_ctor(thread, 1 /* initial tls */); } - if (thread->tcb == NULL) { + thread->siginfo = calloc(_SIG_MAXSIG, sizeof(siginfo_t)); + if ((thread->tcb == NULL) || (thread->siginfo == NULL)) { + if (thread->siginfo != NULL) + free(thread->siginfo); free(thread); thread = NULL; } else { - thread->siginfo = calloc(_SIG_MAXSIG, - sizeof(siginfo_t)); /* * Initialize thread locking. * Lock initializing needs malloc, so don't diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index aec254122a5..85d9b33fafa 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -2372,12 +2372,13 @@ _thr_alloc(struct pthread *curthread) } else { thread->tcb = _tcb_ctor(thread, 1 /* initial tls */); } - if (thread->tcb == NULL) { + thread->siginfo = calloc(_SIG_MAXSIG, sizeof(siginfo_t)); + if ((thread->tcb == NULL) || (thread->siginfo == NULL)) { + if (thread->siginfo != NULL) + free(thread->siginfo); free(thread); thread = NULL; } else { - thread->siginfo = calloc(_SIG_MAXSIG, - sizeof(siginfo_t)); /* * Initialize thread locking. * Lock initializing needs malloc, so don't