@@ -232,6 +232,7 @@ PHPAPI void php_stream_error_state_cleanup(void)
232232 php_stream_error_state * state = & FG (stream_error_state );
233233
234234 state -> operation_floor = 0 ;
235+ state -> refused_operations = 0 ;
235236 while (state -> current_operation ) {
236237 php_stream_error_operation * op = state -> current_operation ;
237238 state -> operation_depth -- ;
@@ -301,6 +302,7 @@ PHPAPI php_stream_error_operation *php_stream_error_operation_begin(void)
301302 php_error_docref (NULL , E_WARNING ,
302303 "Stream error operation depth exceeded (%" PRIu32 "), possible infinite recursion" ,
303304 state -> operation_depth );
305+ state -> refused_operations ++ ;
304306 return NULL ;
305307 }
306308
@@ -337,7 +339,10 @@ static void php_stream_error_add(zend_enum_StreamErrorCode code, const char *wra
337339 zend_string * message , const char * docref , int severity , bool terminating )
338340{
339341 php_stream_error_operation * op = FG (stream_error_state ).current_operation ;
340- ZEND_ASSERT (op != NULL );
342+ if (!op ) {
343+ zend_string_release (message );
344+ return ;
345+ }
341346
342347 php_stream_error_entry * entry = emalloc (sizeof (php_stream_error_entry ));
343348 entry -> message = message ;
@@ -446,6 +451,11 @@ PHPAPI void php_stream_error_operation_end(const php_stream_context *context)
446451 php_stream_error_state * state = & FG (stream_error_state );
447452 php_stream_error_operation * op = state -> current_operation ;
448453
454+ if (state -> refused_operations > 0 ) {
455+ state -> refused_operations -- ;
456+ return ;
457+ }
458+
449459 if (!op ) {
450460 return ;
451461 }
@@ -552,6 +562,11 @@ PHPAPI void php_stream_error_operation_end_for_stream(const php_stream *stream)
552562 php_stream_error_state * state = & FG (stream_error_state );
553563 php_stream_error_operation * op = state -> current_operation ;
554564
565+ if (state -> refused_operations > 0 ) {
566+ state -> refused_operations -- ;
567+ return ;
568+ }
569+
555570 if (!op ) {
556571 return ;
557572 }
@@ -574,6 +589,11 @@ PHPAPI void php_stream_error_operation_abort(void)
574589 php_stream_error_state * state = & FG (stream_error_state );
575590 php_stream_error_operation * op = state -> current_operation ;
576591
592+ if (state -> refused_operations > 0 ) {
593+ state -> refused_operations -- ;
594+ return ;
595+ }
596+
577597 if (!op ) {
578598 return ;
579599 }
0 commit comments