Commit:    e1fb6ce3657f0397261e95e8dc910a305e50ae1a
Author:    Ilia Alshanetsky <i...@ilia.ws>         Wed, 27 Feb 2013 10:13:01 
-0500
Parents:   a6e115e94e1f84335c75860317bad696c77aad94
Branches:  PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=e1fb6ce3657f0397261e95e8dc910a305e50ae1a

Log:
Added missing calloc() result checks

Changed paths:
  M  shared_alloc_mmap.c
  M  shared_alloc_posix.c
  M  shared_alloc_shm.c
  M  zend_accelerator_blacklist.c


Diff:
diff --git a/shared_alloc_mmap.c b/shared_alloc_mmap.c
index a13d373..961f4fe 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 06441e4..418280a 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 c9a31b0..21a4005 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 5191fdb..48fe958 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;
 }


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to