]> granicus.if.org Git - php/commitdiff
Fixes to stream_get_wrappers() and stream_get_filters() handle hash table layouts...
authorSara Golemon <pollita@php.net>
Sun, 5 Jan 2003 22:24:49 +0000 (22:24 +0000)
committerSara Golemon <pollita@php.net>
Sun, 5 Jan 2003 22:24:49 +0000 (22:24 +0000)
ext/standard/file.c
ext/standard/user_filters.c

index 8903d2ca4df99d7eca39743f7fbc599980676baf..4a6a02d542d32845ca3f8f790f5f32c9821f8018 100644 (file)
@@ -633,7 +633,7 @@ PHP_FUNCTION(stream_get_wrappers)
 {
        HashTable *url_stream_wrappers_hash;
        char *stream_protocol;
-       int stream_protocol_len = 0;
+       int key_flags, stream_protocol_len = 0;
 
        if (ZEND_NUM_ARGS() != 0) {
                WRONG_PARAM_COUNT;
@@ -642,9 +642,10 @@ PHP_FUNCTION(stream_get_wrappers)
        if (url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash()) {
                array_init(return_value);
                for(zend_hash_internal_pointer_reset(url_stream_wrappers_hash);
-                       zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
+                       (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, NULL, 0, NULL)) != HASH_KEY_NON_EXISTANT;
                        zend_hash_move_forward(url_stream_wrappers_hash)) 
-                               add_next_index_string(return_value,stream_protocol,1);
+                               if (key_flags == HASH_KEY_IS_STRING)
+                                       add_next_index_stringl(return_value, stream_protocol, stream_protocol_len, 1);
        } else {
                RETURN_FALSE;
        }
index 97b743899a2877e7b044ebc0f5fa4390e6fad2cd..8302527c45c77ec359b8deed64fe1d6996e8fc02 100644 (file)
@@ -416,16 +416,22 @@ static void filter_item_dtor(struct php_user_filter_data *fdat)
 PHP_FUNCTION(stream_get_filters)
 {
        char *filter_name;
-       int filter_name_len = 0;
+       int key_flags, filter_name_len = 0;
+
+       if (ZEND_NUM_ARGS() != 0) {
+               WRONG_PARAM_COUNT;
+       }
 
        array_init(return_value);
 
        if (BG(user_filter_map)) {
                for(zend_hash_internal_pointer_reset(BG(user_filter_map));
-                       zend_hash_get_current_key_ex(BG(user_filter_map), &filter_name, &filter_name_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
+                       (key_flags = zend_hash_get_current_key_ex(BG(user_filter_map), &filter_name, &filter_name_len, NULL, 0, NULL)) != HASH_KEY_NON_EXISTANT;
                        zend_hash_move_forward(BG(user_filter_map)))
-                               add_next_index_string(return_value, filter_name, 1);
+                               if (key_flags == HASH_KEY_IS_STRING)
+                                       add_next_index_stringl(return_value, filter_name, filter_name_len, 1);
        }
+       /* It's okay to return an empty array if no filters are registered */
 }
 /* }}} */