summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2005-12-08 19:55:13 +0000
committerAntony Dovgal <tony2001@php.net>2005-12-08 19:55:13 +0000
commit0d1efb245b26b73d5a68c0b2e5692ca61f65aff9 (patch)
tree1c17583f445c6c1296aefb4753d42d64f6490c59
parent25de19a2fbec1db3e889ab473a493496c3ba51bb (diff)
downloadphp-git-0d1efb245b26b73d5a68c0b2e5692ca61f65aff9.tar.gz
MFH: fix segfault in SplFileObject when file doesn't exist or cannot be read
-rwxr-xr-xext/spl/spl_directory.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 5349c33d34..f927d86593 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1357,16 +1357,16 @@ SPL_METHOD(SplFileObject, __construct)
return;
}
- spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC);
-
- p1 = strrchr(intern->file_name, '/');
- p2 = strrchr(intern->file_name, '\\');
- if (p1 || p2) {
- intern->path_len = (p1 > p2 ? p1 : p2) - intern->file_name;
- } else {
- intern->path_len = 0;
+ if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == SUCCESS) {
+ p1 = strrchr(intern->file_name, '/');
+ p2 = strrchr(intern->file_name, '\\');
+ if (p1 || p2) {
+ intern->path_len = (p1 > p2 ? p1 : p2) - intern->file_name;
+ } else {
+ intern->path_len = 0;
+ }
+ intern->path = estrndup(intern->file_name, intern->path_len);
}
- intern->path = estrndup(intern->file_name, intern->path_len);
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
} /* }}} */
@@ -1400,10 +1400,10 @@ SPL_METHOD(SplTempFileObject, __construct)
intern->u.file.open_mode_len = 1;
intern->u.file.zcontext = NULL;
- spl_filesystem_file_open(intern, 0, 0 TSRMLS_CC);
-
- intern->path_len = 0;
- intern->path = estrndup("", 0);
+ if (spl_filesystem_file_open(intern, 0, 0 TSRMLS_CC) == SUCCESS) {
+ intern->path_len = 0;
+ intern->path = estrndup("", 0);
+ }
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
} /* }}} */