Skip to content

Commit 93430e2

Browse files
committed
clear only neccessary part of spl_filesystem_object
1 parent 758ca01 commit 93430e2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ext/spl/spl_directory.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ static zend_object *spl_filesystem_object_new_ex(zend_class_entry *class_type)
155155
{
156156
spl_filesystem_object *intern;
157157

158-
intern = zend_object_alloc(sizeof(spl_filesystem_object), class_type);
158+
intern = emalloc(sizeof(spl_filesystem_object) + zend_object_properties_size(class_type));
159+
memset(intern, 0,
160+
MAX(XtOffsetOf(spl_filesystem_object, u.dir.entry),
161+
XtOffsetOf(spl_filesystem_object, u.file.escape) + sizeof(int)));
159162
/* intern->type = SPL_FS_INFO; done by set 0 */
160163
intern->file_class = spl_ce_SplFileObject;
161164
intern->info_class = spl_ce_SplFileInfo;

ext/spl/spl_directory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ struct _spl_filesystem_object {
6868
union {
6969
struct {
7070
php_stream *dirp;
71-
php_stream_dirent entry;
7271
zend_string *sub_path;
7372
int index;
7473
int is_recursive;
7574
zend_function *func_rewind;
7675
zend_function *func_next;
7776
zend_function *func_valid;
77+
php_stream_dirent entry;
7878
} dir;
7979
struct {
8080
php_stream *stream;

0 commit comments

Comments
 (0)