@@ -96,7 +96,7 @@ static inline uint32_t rand_range32(const php_random_algo *algo, php_random_stat
9696 r = algo -> generate (status );
9797 result = result | (r << (total_size * 8 ));
9898 total_size += status -> last_generated_size ;
99- if (status -> last_unsafe ) {
99+ if (EG ( exception ) ) {
100100 return 0 ;
101101 }
102102 } while (total_size < sizeof (uint32_t ));
@@ -122,7 +122,6 @@ static inline uint32_t rand_range32(const php_random_algo *algo, php_random_stat
122122 /* If the requirements cannot be met in a cycles, return fail */
123123 if (++ count > RANDOM_RANGE_ATTEMPTS ) {
124124 zend_throw_error (NULL , "Failed to generate an acceptable random number in %d attempts" , RANDOM_RANGE_ATTEMPTS );
125- status -> last_unsafe = true;
126125 return 0 ;
127126 }
128127
@@ -132,7 +131,7 @@ static inline uint32_t rand_range32(const php_random_algo *algo, php_random_stat
132131 r = algo -> generate (status );
133132 result = result | (r << (total_size * 8 ));
134133 total_size += status -> last_generated_size ;
135- if (status -> last_unsafe ) {
134+ if (EG ( exception ) ) {
136135 return 0 ;
137136 }
138137 } while (total_size < sizeof (uint32_t ));
@@ -153,7 +152,7 @@ static inline uint64_t rand_range64(const php_random_algo *algo, php_random_stat
153152 r = algo -> generate (status );
154153 result = result | (r << (total_size * 8 ));
155154 total_size += status -> last_generated_size ;
156- if (status -> last_unsafe ) {
155+ if (EG ( exception ) ) {
157156 return 0 ;
158157 }
159158 } while (total_size < sizeof (uint64_t ));
@@ -179,7 +178,6 @@ static inline uint64_t rand_range64(const php_random_algo *algo, php_random_stat
179178 /* If the requirements cannot be met in a cycles, return fail */
180179 if (++ count > RANDOM_RANGE_ATTEMPTS ) {
181180 zend_throw_error (NULL , "Failed to generate an acceptable random number in %d attempts" , RANDOM_RANGE_ATTEMPTS );
182- status -> last_unsafe = true;
183181 return 0 ;
184182 }
185183
@@ -189,7 +187,7 @@ static inline uint64_t rand_range64(const php_random_algo *algo, php_random_stat
189187 r = algo -> generate (status );
190188 result = result | (r << (total_size * 8 ));
191189 total_size += status -> last_generated_size ;
192- if (status -> last_unsafe ) {
190+ if (EG ( exception ) ) {
193191 return 0 ;
194192 }
195193 } while (total_size < sizeof (uint64_t ));
@@ -245,7 +243,6 @@ PHPAPI php_random_status *php_random_status_alloc(const php_random_algo *algo, c
245243 php_random_status * status = pecalloc (1 , sizeof (php_random_status ), persistent );
246244
247245 status -> last_generated_size = algo -> generate_size ;
248- status -> last_unsafe = false;
249246 status -> state = algo -> state_size > 0 ? pecalloc (1 , algo -> state_size , persistent ) : NULL ;
250247
251248 return status ;
@@ -254,7 +251,6 @@ PHPAPI php_random_status *php_random_status_alloc(const php_random_algo *algo, c
254251PHPAPI php_random_status * php_random_status_copy (const php_random_algo * algo , php_random_status * old_status , php_random_status * new_status )
255252{
256253 new_status -> last_generated_size = old_status -> last_generated_size ;
257- new_status -> last_unsafe = old_status -> last_unsafe ;
258254 new_status -> state = memcpy (new_status -> state , old_status -> state , algo -> state_size );
259255
260256 return new_status ;
0 commit comments