tony2001                Thu Dec  8 14:55:15 2005 EDT

  Modified files:              (Branch: PHP_5_1)
    /php-src/ext/spl    spl_directory.c 
  Log:
  MFH: 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.45.2.4&r2=1.45.2.5&ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.4 
php-src/ext/spl/spl_directory.c:1.45.2.5
--- php-src/ext/spl/spl_directory.c:1.45.2.4    Mon Nov 28 22:33:57 2005
+++ php-src/ext/spl/spl_directory.c     Thu Dec  8 14:55:13 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.4 2005/11/29 03:33:57 helly Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.5 2005/12/08 19:55:13 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1357,16 +1357,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);
 } /* }}} */
@@ -1400,10 +1400,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);
 } /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to