From: Ilia Alshanetsky Date: Wed, 27 Feb 2013 15:13:01 +0000 (-0500) Subject: Added missing calloc() result checks X-Git-Tag: php-5.5.0beta1~42^2~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1fb6ce3657f0397261e95e8dc910a305e50ae1a;p=php Added missing calloc() result checks --- diff --git a/shared_alloc_mmap.c b/shared_alloc_mmap.c index a13d3730f0..961f4fea9a 100644 --- a/shared_alloc_mmap.c +++ b/shared_alloc_mmap.c @@ -39,6 +39,10 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_ *shared_segments_count = 1; *shared_segments_p = (zend_shared_segment **) calloc(1, sizeof(zend_shared_segment) + sizeof(void *)); + if (!*shared_segments_p) { + *error_in = "calloc"; + return ALLOC_FAILURE; + } shared_segment = (zend_shared_segment *)((char *)(*shared_segments_p) + sizeof(void *)); (*shared_segments_p)[0] = shared_segment; diff --git a/shared_alloc_posix.c b/shared_alloc_posix.c index 06441e4e0f..418280a45a 100644 --- a/shared_alloc_posix.c +++ b/shared_alloc_posix.c @@ -43,6 +43,10 @@ static int create_segments(size_t requested_size, zend_shared_segment_posix ***s *shared_segments_count = 1; *shared_segments_p = (zend_shared_segment_posix **) calloc(1, sizeof(zend_shared_segment_posix) + sizeof(void *)); + if (!*shared_segments_p) { + *error_in = "calloc"; + rerurn ALLOC_FAILURE; + } shared_segment = (zend_shared_segment_posix *)((char *)(*shared_segments_p) + sizeof(void *)); (*shared_segments_p)[0] = shared_segment; diff --git a/shared_alloc_shm.c b/shared_alloc_shm.c index c9a31b07b4..21a4005571 100644 --- a/shared_alloc_shm.c +++ b/shared_alloc_shm.c @@ -88,6 +88,9 @@ static int create_segments(size_t requested_size, zend_shared_segment_shm ***sha *shared_segments_count = ((requested_size - 1) / seg_allocate_size) + 1; *shared_segments_p = (zend_shared_segment_shm **) calloc(1, (*shared_segments_count) * sizeof(zend_shared_segment_shm) + sizeof(void *) * (*shared_segments_count)); + if (!*shared_segments_p) { + return ALLOC_FAILURE; + } shared_segments = (zend_shared_segment_shm *)((char *)(*shared_segments_p) + sizeof(void *) * (*shared_segments_count)); for (i = 0; i < *shared_segments_count; i++) { (*shared_segments_p)[i] = shared_segments + i; diff --git a/zend_accelerator_blacklist.c b/zend_accelerator_blacklist.c index 5191fdb020..48fe958432 100644 --- a/zend_accelerator_blacklist.c +++ b/zend_accelerator_blacklist.c @@ -55,6 +55,10 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist) } blacklist->entries = (zend_blacklist_entry *) calloc(sizeof(zend_blacklist_entry), blacklist->size); + if (!blacklist->entries) { + zend_accel_error(ACCEL_LOG_ERROR, "Blacklist initialization: no memory\n"); + return; + } blacklist->regexp_list = NULL; }