]> granicus.if.org Git - php/commitdiff
- Fixed bug #27822 (is_resource() returns TRUE for closed resources)
authorDerick Rethans <derick@php.net>
Thu, 1 Apr 2004 08:54:44 +0000 (08:54 +0000)
committerDerick Rethans <derick@php.net>
Thu, 1 Apr 2004 08:54:44 +0000 (08:54 +0000)
ext/standard/tests/general_functions/is_resource.phpt [new file with mode: 0644]
ext/standard/type.c

diff --git a/ext/standard/tests/general_functions/is_resource.phpt b/ext/standard/tests/general_functions/is_resource.phpt
new file mode 100644 (file)
index 0000000..d44461e
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #27822: is_resource() returns TRUE for closed resources
+--FILE--
+<?php
+       $f = fopen(__FILE__, 'r');
+       fclose($f);
+       var_dump(is_resource($f));
+?>
+--EXPECT--
+bool(false)
index 296353decd46d62a642aa01a428ae67454363190..3005df1dce56eb9f88697f8efee597dd5c0e229e 100644 (file)
@@ -218,6 +218,13 @@ static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
                                RETURN_FALSE;
                        }
                }
+               if (type == IS_RESOURCE) {
+                       char *type_name;
+                       type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg) TSRMLS_CC);
+                       if (!type_name) {
+                               RETURN_FALSE;
+                       }
+               }
                RETURN_TRUE;
        } else {
                RETURN_FALSE;