cvs: php-src /ext/spl spl_directory.c
| From: | Antony Dovgal | Date: | Thu, 08 Dec 2005 19:53:45 +0000 |
| Subject: | cvs: php-src /ext/spl spl_directory.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-35811@lists.php.net to get a copy of this message | ||
tony2001 Thu Dec 8 14:53:45 2005 EDT
Modified files:
/php-src/ext/spl spl_directory.c
Log:
fix segfault in SplFileObject when file doesn't exist or cannot be read
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.57&r2=1.58&ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.57 php-src/ext/spl/spl_directory.c:1.58
--- php-src/ext/spl/spl_directory.c:1.57 Sun Nov 27 08:07:18 2005
+++ php-src/ext/spl/spl_directory.c Thu Dec 8 14:53:43 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.57 2005/11/27 13:07:18 helly Exp $ */
+/* $Id: spl_directory.c,v 1.58 2005/12/08 19:53:43 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -1353,16 +1353,16 @@
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);
} /* }}} */
@@ -1396,10 +1396,10 @@
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);
} /* }}} */