@@ -89,13 +89,21 @@ static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement
8989 ht -> pDestructor = NULL ;
9090
9191 if (!(ht -> u .flags & HASH_FLAG_INITIALIZED )) {
92- HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
92+ if (EXPECTED (!ZCG (current_persistent_script )-> corrupted )) {
93+ HT_SET_DATA_ADDR (ht , & ZCSG (uninitialized_bucket ));
94+ } else {
95+ HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
96+ }
9397 return ;
9498 }
9599 if (ht -> nNumUsed == 0 ) {
96100 efree (HT_GET_DATA_ADDR (ht ));
97101 ht -> nTableMask = HT_MIN_MASK ;
98- HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
102+ if (EXPECTED (!ZCG (current_persistent_script )-> corrupted )) {
103+ HT_SET_DATA_ADDR (ht , & ZCSG (uninitialized_bucket ));
104+ } else {
105+ HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
106+ }
99107 ht -> u .flags &= ~HASH_FLAG_INITIALIZED ;
100108 return ;
101109 }
@@ -175,13 +183,21 @@ static void zend_hash_persist_immutable(HashTable *ht)
175183 ht -> pDestructor = NULL ;
176184
177185 if (!(ht -> u .flags & HASH_FLAG_INITIALIZED )) {
178- HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
186+ if (EXPECTED (!ZCG (current_persistent_script )-> corrupted )) {
187+ HT_SET_DATA_ADDR (ht , & ZCSG (uninitialized_bucket ));
188+ } else {
189+ HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
190+ }
179191 return ;
180192 }
181193 if (ht -> nNumUsed == 0 ) {
182194 efree (HT_GET_DATA_ADDR (ht ));
183195 ht -> nTableMask = HT_MIN_MASK ;
184- HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
196+ if (EXPECTED (!ZCG (current_persistent_script )-> corrupted )) {
197+ HT_SET_DATA_ADDR (ht , & ZCSG (uninitialized_bucket ));
198+ } else {
199+ HT_SET_DATA_ADDR (ht , & uninitialized_bucket );
200+ }
185201 ht -> u .flags &= ~HASH_FLAG_INITIALIZED ;
186202 return ;
187203 }
@@ -833,9 +849,16 @@ static void zend_accel_persist_class_table(HashTable *class_table)
833849 zend_hash_apply (class_table , (apply_func_t ) zend_update_parent_ce );
834850}
835851
836- zend_persistent_script * zend_accel_script_persist (zend_persistent_script * script , char * * key , unsigned int key_length )
852+ zend_persistent_script * zend_accel_script_persist (zend_persistent_script * script , char * * key , unsigned int key_length , int for_shm )
837853{
838854 script -> mem = ZCG (mem );
855+ script -> corrupted = 0 ;
856+ ZCG (current_persistent_script ) = script ;
857+
858+ if (!for_shm ) {
859+ /* script is not going to be saved in SHM */
860+ script -> corrupted = 1 ;
861+ }
839862
840863 ZEND_ASSERT (((zend_uintptr_t )ZCG (mem ) & 0x7 ) == 0 ); /* should be 8 byte aligned */
841864 zend_shared_alloc_clear_xlat_table ();
@@ -860,6 +883,9 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script
860883 zend_hash_persist (& script -> script .function_table , zend_persist_op_array );
861884 zend_persist_op_array_ex (& script -> script .main_op_array , script );
862885
886+ script -> corrupted = 0 ;
887+ ZCG (current_persistent_script ) = NULL ;
888+
863889 return script ;
864890}
865891
0 commit comments