]> granicus.if.org Git - php/commitdiff
Fixed #46051 (SplFileInfo::openFile - memory overlap)
authorArnaud Le Blanc <lbarnaud@php.net>
Thu, 11 Sep 2008 15:22:17 +0000 (15:22 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Thu, 11 Sep 2008 15:22:17 +0000 (15:22 +0000)
ext/spl/spl_directory.c
ext/spl/tests/bug46051.phpt [new file with mode: 0644]

index e61098b192d91f226eebea238f81311d6ee67950..40f196266a356ae8243389525047c8f235aa2a2b 100755 (executable)
@@ -533,6 +533,7 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil
                                        &use_include_path, &intern->u.file.zcontext) == FAILURE) {
                                zend_restore_error_handling(&error_handling TSRMLS_CC);
                                intern->u.file.open_mode = NULL;
+                               intern->file_name.v = NULL;
                                zval_dtor(return_value);
                                Z_TYPE_P(return_value) = IS_NULL;
                                return NULL;
diff --git a/ext/spl/tests/bug46051.phpt b/ext/spl/tests/bug46051.phpt
new file mode 100644 (file)
index 0000000..49a5824
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #46051 (SplFileInfo::openFile - memory overlap)
+--FILE--
+<?php
+
+$x = new splfileinfo(__FILE__);
+
+try {
+$x->openFile(NULL, NULL, NULL);
+} catch (Exception $e) { }
+
+var_dump($x->getPathName());
+--EXPECTF--
+%unicode|string%(%d) "%sbug46051.php"