summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2004-01-20 11:35:32 +0000
committerRob Richards <rrichards@php.net>2004-01-20 11:35:32 +0000
commita4815f7c8e9e7a5f5ccd9850402afc434f1d4353 (patch)
tree4f5589ac0c1b3889d0a080d5281ca76c52ce3e8b /ext
parent42110742b74c50779564a871d6e1211bea9203ef (diff)
downloadphp-git-a4815f7c8e9e7a5f5ccd9850402afc434f1d4353.tar.gz
Warn when empty string supplied to load methods (by Pierre-Alain)
Fix refcount on xpath iterators xpath_query should return nodelist even when empty
Diffstat (limited to 'ext')
-rw-r--r--ext/dom/document.c6
-rw-r--r--ext/dom/dom_iterators.c2
-rw-r--r--ext/dom/xpath.c2
3 files changed, 9 insertions, 1 deletions
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);