summaryrefslogtreecommitdiff
path: root/ext/dom/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dom/node.c')
-rw-r--r--ext/dom/node.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/ext/dom/node.c b/ext/dom/node.c
index b0aa096..d684336 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -86,6 +86,11 @@ int dom_node_node_name_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
switch (nodep->type) {
case XML_ATTRIBUTE_NODE:
case XML_ELEMENT_NODE:
@@ -170,6 +175,12 @@ int dom_node_node_value_read(dom_object *obj, zval **retval TSRMLS_DC)
char *str = NULL;
nodep = dom_object_get_node(obj);
+
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
/* Access to Element node is implemented as a convience method */
switch (nodep->type) {
case XML_ATTRIBUTE_NODE:
@@ -209,6 +220,11 @@ int dom_node_node_value_write(dom_object *obj, zval *newval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
/* Access to Element node is implemented as a convience method */
switch (nodep->type) {
case XML_ELEMENT_NODE:
@@ -255,6 +271,11 @@ int dom_node_node_type_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
ALLOC_ZVAL(*retval);
/* Specs dictate that they are both type XML_DOCUMENT_TYPE_NODE */
@@ -283,6 +304,11 @@ int dom_node_parent_node_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
nodeparent = nodep->parent;
if (!nodeparent) {
return FAILURE;
@@ -313,6 +339,11 @@ int dom_node_child_nodes_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
ALLOC_ZVAL(*retval);
if (dom_node_children_valid(nodep) == FAILURE) {
@@ -342,6 +373,11 @@ int dom_node_first_child_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
if (dom_node_children_valid(nodep) == SUCCESS) {
first = nodep->children;
}
@@ -375,6 +411,11 @@ int dom_node_last_child_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
if (dom_node_children_valid(nodep) == SUCCESS) {
last = nodep->last;
}
@@ -408,6 +449,11 @@ int dom_node_previous_sibling_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
prevsib = nodep->prev;
if (!prevsib) {
return FAILURE;
@@ -438,6 +484,11 @@ int dom_node_next_sibling_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
nextsib = nodep->next;
if (!nextsib) {
return FAILURE;
@@ -468,6 +519,11 @@ int dom_node_attributes_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
ALLOC_ZVAL(*retval);
if (nodep->type == XML_ELEMENT_NODE) {
@@ -498,6 +554,11 @@ int dom_node_owner_document_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
ALLOC_ZVAL(*retval);
ZVAL_NULL(*retval);
@@ -534,6 +595,11 @@ int dom_node_namespace_uri_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
switch (nodep->type) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
@@ -575,6 +641,11 @@ int dom_node_prefix_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
switch (nodep->type) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
@@ -611,6 +682,11 @@ int dom_node_prefix_write(dom_object *obj, zval *newval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
switch (nodep->type) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
@@ -682,6 +758,11 @@ int dom_node_local_name_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
ALLOC_ZVAL(*retval);
if (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE || nodep->type == XML_NAMESPACE_DECL) {
@@ -709,6 +790,11 @@ int dom_node_base_uri_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
ALLOC_ZVAL(*retval);
baseuri = xmlNodeGetBase(nodep->doc, nodep);
@@ -738,6 +824,11 @@ int dom_node_text_content_read(dom_object *obj, zval **retval TSRMLS_DC)
nodep = dom_object_get_node(obj);
+ if (nodep == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
+ return FAILURE;
+ }
+
str = xmlNodeGetContent(nodep);
ALLOC_ZVAL(*retval);