@@ -793,13 +793,18 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
793
793
is_string :
794
794
resource = Z_STRVAL (retval );
795
795
} else if (Z_TYPE (retval ) == IS_RESOURCE ) {
796
- php_stream * stream ;
797
- php_stream_from_zval_no_verify (stream , & retval );
798
- if (stream == NULL ) {
799
- php_libxml_ctx_error (context ,
800
- "The user entity loader callback '%s' has returned a "
801
- "resource, but it is not a stream" ,
802
- ZSTR_VAL (LIBXML (entity_loader_callback ).function_handler -> common .function_name ));
796
+ php_stream * stream = (php_stream * )zend_fetch_resource2_ex (& retval , NULL , php_file_le_stream (), php_file_le_pstream ());
797
+ if (UNEXPECTED (stream == NULL )) {
798
+ zval callable ;
799
+ zend_get_callable_zval_from_fcc (& LIBXML (entity_loader_callback ), & callable );
800
+ zend_string * callable_name = zend_get_callable_name (& callable );
801
+ zend_string * func_name = get_active_function_or_method_name ();
802
+ zend_type_error (
803
+ "%s(): The user entity loader callback \"%s\" has returned a resource, but it is not a stream" ,
804
+ ZSTR_VAL (func_name ), ZSTR_VAL (callable_name ));
805
+ zend_string_release (func_name );
806
+ zend_string_release (callable_name );
807
+ zval_ptr_dtor (& callable );
803
808
} else {
804
809
/* TODO: allow storing the encoding in the stream context? */
805
810
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE ;
0 commit comments