From 35f6f9b0dbc683812badf3a8e38d1ec110fd7925 Mon Sep 17 00:00:00 2001 From: Yussuf Khalil Date: Wed, 10 Feb 2016 10:33:57 +0100 Subject: [PATCH] Fix use-after-free of ZCG(cwd) in Zend Optimizer --- ext/opcache/ZendAccelerator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 66b54f2ebf..0f66c56ea6 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2370,6 +2370,11 @@ static void accel_deactivate(void) */ TSRMLS_FETCH(); + if (ZCG(cwd)) { + efree(ZCG(cwd)); + ZCG(cwd) = NULL; + } + if (!ZCG(enabled) || !accel_startup_ok) { return; } @@ -2383,12 +2388,6 @@ static void accel_deactivate(void) zend_accel_fast_shutdown(TSRMLS_C); } #endif - - if (ZCG(cwd)) { - efree(ZCG(cwd)); - ZCG(cwd) = NULL; - } - } static int accelerator_remove_cb(zend_extension *element1, zend_extension *element2) -- 2.40.0