]> granicus.if.org Git - php/commitdiff
Added missing calloc() result checks
authorIlia Alshanetsky <ilia@ilia.ws>
Wed, 27 Feb 2013 15:13:01 +0000 (10:13 -0500)
committerIlia Alshanetsky <ilia@ilia.ws>
Wed, 27 Feb 2013 15:13:01 +0000 (10:13 -0500)
shared_alloc_mmap.c
shared_alloc_posix.c
shared_alloc_shm.c
zend_accelerator_blacklist.c

index a13d3730f0a1a1a3e96cc5bd7d21debb61725f4c..961f4fea9afd6a3d93df123dbf1d9ef27f6b0b5a 100644 (file)
@@ -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;
 
index 06441e4e0fbee64ae03ea3ad4f98a37430149a66..418280a45ac29ee58953433294e0063cd0a04a70 100644 (file)
@@ -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;
 
index c9a31b07b402232e907ed2fdbe01e957bfde0f86..21a4005571d27afd6065bf5f4deb95b22fa29edb 100644 (file)
@@ -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;
index 5191fdb0209d7c3a7b61939093eb403115b47564..48fe958432a59a8ded7ad0e4e54f61e098bf633d 100644 (file)
@@ -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;
 }