com php-src: Clear alocated memory blocks, only if this is really necessary.: ext/opcache/ZendAccelerator.c ext/opcache/zend_sh ared_alloc.c

From: Date: Wed, 21 Jun 2017 07:37:54 +0000
Subject: com php-src: Clear alocated memory blocks, only if this is really necessary.: ext/opcache/ZendAccelerator.c ext/opcache/zend_sh ared_alloc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-98147@lists.php.net to get a copy of this message
Commit: c16f954ff199abe1cd83f97897c3c65d82e92961 Author: Dmitry Stogov <dmitry@zend.com> Wed, 21 Jun 2017 10:37:54 +0300 Parents: 1dfb63feca0fd4ae7f95d93d7291e4711b498b1f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c16f954ff199abe1cd83f97897c3c65d82e92961 Log: Clear alocated memory blocks, only if this is really necessary. Changed paths: M ext/opcache/ZendAccelerator.c M ext/opcache/zend_shared_alloc.c Diff: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index c2ff267..812b448 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1361,9 +1361,15 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr #ifdef __SSE2__ /* Align to 64-byte boundary */ ZCG(mem) = zend_shared_alloc(memory_used + 64); - ZCG(mem) = (void*)(((zend_uintptr_t)ZCG(mem) + 63L) & ~63L); + if (ZCG(mem)) { + memset(ZCG(mem), 0, memory_used + 64); + ZCG(mem) = (void*)(((zend_uintptr_t)ZCG(mem) + 63L) & ~63L); + } #else ZCG(mem) = zend_shared_alloc(memory_used); + if (ZCG(mem)) { + memset(ZCG(mem), 0, memory_used); + } #endif if (!ZCG(mem)) { zend_shared_alloc_destroy_xlat_table(); @@ -2542,6 +2548,7 @@ static int zend_accel_init_shm(void) zend_shared_alloc_unlock(); return FAILURE; } + memset(accel_shared_globals, 0, sizeof(zend_accel_shared_globals)); ZSMMG(app_shared_globals) = accel_shared_globals; zend_accel_hash_init(&ZCSG(hash), ZCG(accel_directives).max_accelerated_files); diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index b7940ad..738c628 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -230,6 +230,7 @@ int zend_shared_alloc_startup(size_t requested_size) zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); return ALLOC_FAILURE;; } + memset(p_tmp_shared_globals, 0, sizeof(zend_smm_shared_globals)); tmp_shared_segments = zend_shared_alloc(shared_segments_array_size + ZSMMG(shared_segments_count) * sizeof(void *)); if (!tmp_shared_segments) { @@ -325,7 +326,6 @@ void *zend_shared_alloc(size_t size) ZSMMG(shared_segments)[i]->pos += block_size; ZSMMG(shared_free) -= block_size; - memset(retval, 0, block_size); ZEND_ASSERT(((zend_uintptr_t)retval & 0x7) == 0); /* should be 8 byte aligned */ return retval; }

« previous php.cvs (#98147) next »