From: Nicholas Clark Date: Fri, 16 Jul 2004 08:53:28 +0000 (+0000) Subject: Some calls to PerlMemShared_alloc() aren't checking the return value. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8043fdafce9b64db18484779a548e4f4adefc5ed;p=p5sagit%2Fp5-mst-13.2.git Some calls to PerlMemShared_alloc() aren't checking the return value. Bug spotted by Nigel Sandever p4raw-id: //depot/perl@23121 --- diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index 4148fb0..00ef0aa 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -389,6 +389,12 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param MUTEX_LOCK(&create_destruct_mutex); thread = PerlMemShared_malloc(sizeof(ithread)); + if (!thread) { + MUTEX_UNLOCK(&create_destruct_mutex); + PerlLIO_write(PerlIO_fileno(Perl_error_log), + PL_no_mem, strlen(PL_no_mem)); + my_exit(1); + } Zero(thread,1,ithread); thread->next = threads; thread->prev = threads->prev; @@ -755,6 +761,11 @@ BOOT: MUTEX_LOCK(&create_destruct_mutex); PL_threadhook = &Perl_ithread_hook; thread = PerlMemShared_malloc(sizeof(ithread)); + if (!thread) { + PerlLIO_write(PerlIO_fileno(Perl_error_log), + PL_no_mem, strlen(PL_no_mem)); + my_exit(1); + } Zero(thread,1,ithread); PL_perl_destruct_level = 2; MUTEX_INIT(&thread->mutex); diff --git a/util.c b/util.c index 1892fec..030c706 100644 --- a/util.c +++ b/util.c @@ -803,6 +803,11 @@ Perl_savesharedpv(pTHX_ const char *pv) register char *newaddr = Nullch; if (pv) { newaddr = (char*)PerlMemShared_malloc(strlen(pv)+1); + if (!newaddr) { + PerlLIO_write(PerlIO_fileno(Perl_error_log), + PL_no_mem, strlen(PL_no_mem)); + my_exit(1); + } (void)strcpy(newaddr,pv); } return newaddr;