From: Rob Richards Date: Tue, 20 Jan 2004 11:35:32 +0000 (+0000) Subject: Warn when empty string supplied to load methods (by Pierre-Alain) X-Git-Tag: php_ibase_before_split~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4815f7c8e9e7a5f5ccd9850402afc434f1d4353;p=php Warn when empty string supplied to load methods (by Pierre-Alain) Fix refcount on xpath iterators xpath_query should return nodelist even when empty --- diff --git a/ext/dom/document.c b/ext/dom/document.c index 85f9ff0030..22e40e6752 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -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; } diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index f71bc60e0e..6e027c243e 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -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); diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 76767fa1f7..28b118e50c 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -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);