]> granicus.if.org Git - php/commitdiff
MFH: fix double free(), add test
authorAntony Dovgal <tony2001@php.net>
Fri, 15 Sep 2006 07:27:22 +0000 (07:27 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 15 Sep 2006 07:27:22 +0000 (07:27 +0000)
ext/standard/tests/file/stream_001.phpt [new file with mode: 0644]
main/streams/streams.c

diff --git a/ext/standard/tests/file/stream_001.phpt b/ext/standard/tests/file/stream_001.phpt
new file mode 100644 (file)
index 0000000..8a3f034
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+stream_wrapper_unregister() & stream_wrapper_restore()
+--FILE--
+<?php
+
+var_dump(stream_wrapper_unregister('file'));
+var_dump(fopen("file://".__FILE__, "r"));
+var_dump(stream_wrapper_restore('file'));
+var_dump(fopen("file://".__FILE__, "r"));
+
+echo "Done\n";
+?>
+--EXPECTF--    
+bool(true)
+
+Notice: fopen(): Unable to find the wrapper "file" - did you forget to enable it when you configured PHP? in %s on line %d
+
+Warning: fopen(): Plainfiles wrapper disabled in %s on line %d
+
+Warning: fopen(file:///%s): failed to open stream: no suitable wrapper could be found in %s on line %d
+bool(false)
+bool(true)
+resource(%d) of type (stream)
+Done
index 70f4c46daf20a4346ffb5226c1528f5148157c57..55b0485ea34d0be16b59a60731fc084f71f30203 100755 (executable)
@@ -1528,7 +1528,6 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
                        if (FAILURE == zend_hash_find(wrapper_hash, (char*)tmp, n, (void**)&wrapperpp)) {
                                char wrapper_name[32];
 
-                               efree(tmp);
                                if (n >= sizeof(wrapper_name)) {
                                        n = sizeof(wrapper_name) - 1;
                                }