Skip to content

Commit

Permalink
Fixed use-after-free
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Mar 14, 2018
1 parent d2b47e8 commit b6a41ad
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ext/opcache/zend_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,6 @@ static void zend_accel_persist_class_table(HashTable *class_table)
zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length, int for_shm)
{
script->mem = ZCG(mem);
script->corrupted = 0;
ZCG(current_persistent_script) = script;

if (!for_shm) {
/* script is not going to be saved in SHM */
script->corrupted = 1;
}

ZEND_ASSERT(((zend_uintptr_t)ZCG(mem) & 0x7) == 0); /* should be 8 byte aligned */
zend_shared_alloc_clear_xlat_table();
Expand All @@ -867,6 +860,15 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script
if (key && *key) {
*key = zend_accel_memdup(*key, key_length + 1);
}

script->corrupted = 0;
ZCG(current_persistent_script) = script;

if (!for_shm) {
/* script is not going to be saved in SHM */
script->corrupted = 1;
}

zend_accel_store_string(script->script.filename);

#ifdef __SSE2__
Expand Down

0 comments on commit b6a41ad

Please sign in to comment.