@@ -72,6 +72,36 @@ static void spl_filesystem_file_free_line(spl_filesystem_object *intern) /* {{{
72
72
}
73
73
} /* }}} */
74
74
75
+ static void spl_filesystem_object_destroy_object (zend_object * object ) /* {{{ */
76
+ {
77
+ spl_filesystem_object * intern = spl_filesystem_from_obj (object );
78
+
79
+ zend_objects_destroy_object (object );
80
+
81
+ switch (intern -> type ) {
82
+ case SPL_FS_DIR :
83
+ if (intern -> u .dir .dirp ) {
84
+ php_stream_close (intern -> u .dir .dirp );
85
+ intern -> u .dir .dirp = NULL ;
86
+ }
87
+ break ;
88
+ case SPL_FS_FILE :
89
+ if (intern -> u .file .stream ) {
90
+ /*
91
+ if (intern->u.file.zcontext) {
92
+ zend_list_delref(Z_RESVAL_P(intern->zcontext));
93
+ }
94
+ */
95
+ if (!intern -> u .file .stream -> is_persistent ) {
96
+ php_stream_close (intern -> u .file .stream );
97
+ } else {
98
+ php_stream_pclose (intern -> u .file .stream );
99
+ }
100
+ }
101
+ break ;
102
+ }
103
+ } /* }}} */
104
+
75
105
static void spl_filesystem_object_free_storage (zend_object * object ) /* {{{ */
76
106
{
77
107
spl_filesystem_object * intern = spl_filesystem_from_obj (object );
@@ -92,26 +122,12 @@ static void spl_filesystem_object_free_storage(zend_object *object) /* {{{ */
92
122
case SPL_FS_INFO :
93
123
break ;
94
124
case SPL_FS_DIR :
95
- if (intern -> u .dir .dirp ) {
96
- php_stream_close (intern -> u .dir .dirp );
97
- intern -> u .dir .dirp = NULL ;
98
- }
99
125
if (intern -> u .dir .sub_path ) {
100
126
efree (intern -> u .dir .sub_path );
101
127
}
102
128
break ;
103
129
case SPL_FS_FILE :
104
130
if (intern -> u .file .stream ) {
105
- /*
106
- if (intern->u.file.zcontext) {
107
- zend_list_delref(Z_RESVAL_P(intern->zcontext));
108
- }
109
- */
110
- if (!intern -> u .file .stream -> is_persistent ) {
111
- php_stream_close (intern -> u .file .stream );
112
- } else {
113
- php_stream_pclose (intern -> u .file .stream );
114
- }
115
131
if (intern -> u .file .open_mode ) {
116
132
efree (intern -> u .file .open_mode );
117
133
}
@@ -3108,7 +3124,7 @@ PHP_MINIT_FUNCTION(spl_directory)
3108
3124
spl_filesystem_object_handlers .clone_obj = spl_filesystem_object_clone ;
3109
3125
spl_filesystem_object_handlers .cast_object = spl_filesystem_object_cast ;
3110
3126
spl_filesystem_object_handlers .get_debug_info = spl_filesystem_object_get_debug_info ;
3111
- spl_filesystem_object_handlers .dtor_obj = zend_objects_destroy_object ;
3127
+ spl_filesystem_object_handlers .dtor_obj = spl_filesystem_object_destroy_object ;
3112
3128
spl_filesystem_object_handlers .free_obj = spl_filesystem_object_free_storage ;
3113
3129
spl_ce_SplFileInfo -> serialize = zend_class_serialize_deny ;
3114
3130
spl_ce_SplFileInfo -> unserialize = zend_class_unserialize_deny ;
0 commit comments