Skip to content

Commit 1c542af

Browse files
committed
Revert undoing of partial spl_filesystem_object initialization
We're intentionally not initializing spl_filesystem_object.u.dir.entry, as it will later be initialized, and we don't need to zero the entire buffer anyway.
1 parent c82cea0 commit 1c542af

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/spl/spl_directory.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ static zend_object *spl_filesystem_object_new(zend_class_entry *class_type)
187187
{
188188
spl_filesystem_object *intern;
189189

190-
intern = ecalloc(1, sizeof(spl_filesystem_object) + zend_object_properties_size(class_type));
190+
intern = emalloc(sizeof(spl_filesystem_object) + zend_object_properties_size(class_type));
191+
/* Avoid initializing the entirety of spl_filesystem_object.u.dir.entry. */
192+
memset(intern, 0,
193+
MAX(XtOffsetOf(spl_filesystem_object, u.dir.entry),
194+
XtOffsetOf(spl_filesystem_object, u.file.escape) + sizeof(int)));
191195
/* intern->type = SPL_FS_INFO; done by set 0 */
192196
intern->file_class = spl_ce_SplFileObject;
193197
intern->info_class = spl_ce_SplFileInfo;

0 commit comments

Comments
 (0)