diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index ca54db7ef3c..8100ba83a64 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -636,7 +636,7 @@ static inline HashTable *spl_filesystem_object_get_debug_info(zend_object *objec } if (intern->type == SPL_FS_DIR) { #ifdef HAVE_GLOB - if (php_stream_is(intern->u.dir.dirp, &php_glob_stream_ops)) { + if (intern->u.dir.dirp && php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) { ZVAL_STR_COPY(&tmp, intern->path); } else { ZVAL_FALSE(&tmp); diff --git a/ext/spl/tests/gh14687.phpt b/ext/spl/tests/gh14687.phpt new file mode 100644 index 00000000000..1e95d6b6517 --- /dev/null +++ b/ext/spl/tests/gh14687.phpt @@ -0,0 +1,49 @@ +--TEST-- +GH-14687 segfault on debugging SplObjectStorage instance after __destruct. +--CREDITS-- +YuanchengJiang +--EXTENSIONS-- +phar +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- + +--CLEAN-- + +--EXPECT-- +object(SplObjectStorage)#2 (1) { + ["storage":"SplObjectStorage":private]=> + array(1) { + [0]=> + array(2) { + ["obj"]=> + object(Phar)#1 (3) { + ["pathName":"SplFileInfo":private]=> + string(0) "" + ["glob":"DirectoryIterator":private]=> + bool(false) + ["subPathName":"RecursiveDirectoryIterator":private]=> + string(0) "" + } + ["inf"]=> + object(HasDestructor)#3 (0) { + } + } + } +}