Skip to content

Commit 2342c06

Browse files
committed
Throw an exception if default_dir not set, but required
Previously the RETURN_THROWS() assertion failed for this case.
1 parent d91abf7 commit 2342c06

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

ext/standard/dir.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ static zend_class_entry *dir_class_entry_ptr;
7474
RETURN_THROWS(); \
7575
} \
7676
} else { \
77-
if (!DIRG(default_dir) || \
78-
(dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
77+
if (!DIRG(default_dir)) { \
78+
zend_type_error("No resource supplied"); \
79+
RETURN_THROWS(); \
80+
} else if ((dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
7981
RETURN_THROWS(); \
8082
} \
8183
} \
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Calling closedir() without argument and without opening a directory beforehand
3+
--FILE--
4+
<?php
5+
try {
6+
closedir();
7+
} catch (TypeError $e) {
8+
echo $e->getMessage(), "\n";
9+
}
10+
?>
11+
--EXPECT--
12+
No resource supplied

0 commit comments

Comments
 (0)