rasmus Mon Oct 7 12:46:38 2002 EDT
Modified files:
/php4/ext/standard dir.c
Log:
readdir() was returning NULL instead of FALSE when used on an invalid
directory handle. If someone forgot to check (as someone here did) that
the opendir() succeeded, and then followed the documented usage by checking
readdir()!==FALSE things would go awry. The ZEND_FETCH_RESOURCE macro
explicitly does a RETURN_NULL on failure which is not what we want in this
case, so work around it. No need to change it for the OO case since the
object is not created if the opendir fails.
Index: php4/ext/standard/dir.c
diff -u php4/ext/standard/dir.c:1.107 php4/ext/standard/dir.c:1.108
--- php4/ext/standard/dir.c:1.107 Fri Oct 4 14:03:29 2002
+++ php4/ext/standard/dir.c Mon Oct 7 12:46:38 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dir.c,v 1.107 2002/10/04 18:03:29 rasmus Exp $ */
+/* $Id: dir.c,v 1.108 2002/10/07 16:46:38 rasmus Exp $ */
/* {{{ includes/startup/misc */
@@ -85,7 +85,9 @@
} else if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &id) ==
FAILURE) { \
WRONG_PARAM_COUNT; \
} else { \
- ZEND_FETCH_RESOURCE(dirp, php_stream *, id,-1, "Directory",
php_file_le_stream()); \
+ dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1,
+"Directory", NULL, 1, php_file_le_stream()); \
+ if(!dirp) \
+ RETURN_FALSE; \
}
static zend_function_entry php_dir_class_functions[] = {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php