]> granicus.if.org Git - php/commitdiff
Warn when empty string supplied to load methods (by Pierre-Alain)
authorRob Richards <rrichards@php.net>
Tue, 20 Jan 2004 11:35:32 +0000 (11:35 +0000)
committerRob Richards <rrichards@php.net>
Tue, 20 Jan 2004 11:35:32 +0000 (11:35 +0000)
Fix refcount on xpath iterators
xpath_query should return nodelist even when empty

ext/dom/document.c
ext/dom/dom_iterators.c
ext/dom/xpath.c

index 85f9ff00306e14528552157e8bb32567f77fc46a..22e40e67522d0ae28fb99afa99bdff723236e1f8 100644 (file)
@@ -1288,6 +1288,11 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) {
                return;
        }
 
+       if (!source_len) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string supplied as input");
+               RETURN_FALSE;
+       }
+
        newdoc = dom_document_parser(id, mode, source TSRMLS_CC);
 
        if (!newdoc)
@@ -1721,6 +1726,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode)
        }
 
        if (!source_len) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string supplied as input");
                RETURN_FALSE;
        }
 
index f71bc60e0e204eb35cd469fde88454ddb9252e7b..6e027c243e567856bfef22c9b922271720405cf9 100644 (file)
@@ -206,6 +206,7 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
                                zend_hash_move_forward(nodeht);
                                if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {
                                        curattr = *entry;
+                                       curattr->refcount++;
                                }
                        } else {
                                curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node;
@@ -273,6 +274,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object TS
                        zend_hash_internal_pointer_reset(nodeht);
                        if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {
                                curattr = *entry;
+                               curattr->refcount++;
                        }
                } else {
                        nodep = (xmlNode *)dom_object_get_node(objmap->baseobj);
index 76767fa1f7ef7d3534d41ac5a8a2d1efa374f3c6..28b118e50c544bd35aaf4fe76dc4dcb983cb183f 100644 (file)
@@ -252,7 +252,7 @@ PHP_FUNCTION(dom_xpath_query)
                        add_next_index_zval(retval, child);
                }
        } else {
-               RETURN_FALSE;
+               retval = NULL;
        }
 
        php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC);