@@ -769,13 +769,18 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
769
769
is_string :
770
770
resource = Z_STRVAL (retval );
771
771
} else if (Z_TYPE (retval ) == IS_RESOURCE ) {
772
- php_stream * stream ;
773
- php_stream_from_zval_no_verify (stream , & retval );
774
- if (stream == NULL ) {
775
- php_libxml_ctx_error (context ,
776
- "The user entity loader callback '%s' has returned a "
777
- "resource, but it is not a stream" ,
778
- ZSTR_VAL (LIBXML (entity_loader_callback ).function_handler -> common .function_name ));
772
+ php_stream * stream = (php_stream * )zend_fetch_resource2_ex (& retval , NULL , php_file_le_stream (), php_file_le_pstream ());
773
+ if (UNEXPECTED (stream == NULL )) {
774
+ zval callable ;
775
+ zend_get_callable_zval_from_fcc (& LIBXML (entity_loader_callback ), & callable );
776
+ zend_string * callable_name = zend_get_callable_name (& callable );
777
+ zend_string * func_name = get_active_function_or_method_name ();
778
+ zend_type_error (
779
+ "%s(): The user entity loader callback \"%s\" has returned a resource, but it is not a stream" ,
780
+ ZSTR_VAL (func_name ), ZSTR_VAL (callable_name ));
781
+ zend_string_release (func_name );
782
+ zend_string_release (callable_name );
783
+ zval_ptr_dtor (& callable );
779
784
} else {
780
785
/* TODO: allow storing the encoding in the stream context? */
781
786
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE ;
0 commit comments