[php-src] Issue #7809: Segmentation fault @ PHP 8.1
| From: | cmb69 | Date: | Wed, 22 Dec 2021 13:06:18 +0000 |
| Subject: | [php-src] Issue #7809: Segmentation fault @ PHP 8.1 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238537@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7809
Comment Author: cmb69
The following patch might do:
````.diff
ext/spl/spl_directory.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 1161858468..0ba11f4800 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -385,8 +385,12 @@ static zend_object *spl_filesystem_object_clone(zend_object *old_object)
switch (source->type) {
case SPL_FS_INFO:
- intern->path = zend_string_copy(source->path);
- intern->file_name = zend_string_copy(source->file_name);
+ if (source->path != NULL) {
+ intern->path = zend_string_copy(source->path);
+ }
+ if (source->file_name != NULL) {
+ intern->file_name = zend_string_copy(source->file_name);
+ }
break;
case SPL_FS_DIR:
spl_filesystem_dir_open(intern, source->path);
````