summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2002-10-07 16:46:38 +0000
committerRasmus Lerdorf <rasmus@php.net>2002-10-07 16:46:38 +0000
commitef9b51bcb04e768075898621a28cf1b5a7a1551c (patch)
treef3c9c6d3cf14a18442ad1687326794f6017130c7
parent9b849892eacba70705fa17674f9fdb2242e6036a (diff)
downloadphp-git-ef9b51bcb04e768075898621a28cf1b5a7a1551c.tar.gz
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.
-rw-r--r--ext/standard/dir.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index 7cc982cacc..4512d69ddc 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -85,7 +85,9 @@ static zend_class_entry *dir_class_entry_ptr;
} 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[] = {