mirror of
https://github.com/php/php-src.git
synced 2024-11-25 19:05:31 +08:00
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.
This commit is contained in:
parent
9b849892ea
commit
ef9b51bcb0
@ -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[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user