rrichards               Fri Mar 13 13:43:57 2009 UTC

  Modified files:              
    /php-src/ext/dom    attr.c document.c node.c 
    /php-src/ext/dom/tests      bug47430.phpt 
  Log:
  MFB: fix bug #47430 (Errors after writing to nodeValue parameter of an absent 
previousSibling)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/attr.c?r1=1.38&r2=1.39&diff_format=u
Index: php-src/ext/dom/attr.c
diff -u php-src/ext/dom/attr.c:1.38 php-src/ext/dom/attr.c:1.39
--- php-src/ext/dom/attr.c:1.38 Tue Mar 10 23:39:12 2009
+++ php-src/ext/dom/attr.c      Fri Mar 13 13:43:57 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: attr.c,v 1.38 2009/03/10 23:39:12 helly Exp $ */
+/* $Id: attr.c,v 1.39 2009/03/13 13:43:57 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -220,13 +220,14 @@
                return FAILURE;
        }
 
+       ALLOC_ZVAL(*retval);
+
        nodeparent = nodep->parent;
        if (!nodeparent) {
-               return FAILURE;
+               ZVAL_NULL(*retval);
+               return SUCCESS;
        }
 
-       ALLOC_ZVAL(*retval);
-
        if (NULL == (*retval = php_dom_create_object(nodeparent, &ret, NULL, 
*retval, obj TSRMLS_CC))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING,  "Cannot create 
required DOM object");
                return FAILURE;
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/document.c?r1=1.101&r2=1.102&diff_format=u
Index: php-src/ext/dom/document.c
diff -u php-src/ext/dom/document.c:1.101 php-src/ext/dom/document.c:1.102
--- php-src/ext/dom/document.c:1.101    Tue Mar 10 23:39:12 2009
+++ php-src/ext/dom/document.c  Fri Mar 13 13:43:57 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: document.c,v 1.101 2009/03/10 23:39:12 helly Exp $ */
+/* $Id: document.c,v 1.102 2009/03/13 13:43:57 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -253,12 +253,14 @@
                return FAILURE;
        }
 
+       ALLOC_ZVAL(*retval);
+
        dtdptr = xmlGetIntSubset(docp);
        if (!dtdptr) {
-               return FAILURE;
+               ZVAL_NULL(*retval);
+               return SUCCESS;
        }
 
-       ALLOC_ZVAL(*retval);
        if (NULL == (*retval = php_dom_create_object((xmlNodePtr) dtdptr, &ret, 
NULL, *retval, obj TSRMLS_CC))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create 
required DOM object");
                return FAILURE;
@@ -301,12 +303,14 @@
                return FAILURE;
        }
 
+       ALLOC_ZVAL(*retval);
+
        root = xmlDocGetRootElement(docp);
        if (!root) {
-               return FAILURE;
+               ZVAL_NULL(*retval);
+               return SUCCESS;
        }
 
-       ALLOC_ZVAL(*retval);
        if (NULL == (*retval = php_dom_create_object(root, &ret, NULL, *retval, 
obj TSRMLS_CC))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create 
required DOM object");
                return FAILURE;
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/node.c?r1=1.70&r2=1.71&diff_format=u
Index: php-src/ext/dom/node.c
diff -u php-src/ext/dom/node.c:1.70 php-src/ext/dom/node.c:1.71
--- php-src/ext/dom/node.c:1.70 Tue Mar 10 23:39:13 2009
+++ php-src/ext/dom/node.c      Fri Mar 13 13:43:57 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: node.c,v 1.70 2009/03/10 23:39:13 helly Exp $ */
+/* $Id: node.c,v 1.71 2009/03/13 13:43:57 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -260,7 +260,6 @@
                        break;
                default:
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 
Node Type");
-                       return FAILURE;
        }
 
        ALLOC_ZVAL(*retval);
@@ -422,13 +421,14 @@
                return FAILURE;
        }
 
+       ALLOC_ZVAL(*retval);
+
        nodeparent = nodep->parent;
        if (!nodeparent) {
-               return FAILURE;
+               ZVAL_NULL(*retval);
+               return SUCCESS;
        }
 
-       ALLOC_ZVAL(*retval);
-
        if (NULL == (*retval = php_dom_create_object(nodeparent, &ret, NULL, 
*retval, obj TSRMLS_CC))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create 
required DOM object");
                return FAILURE;
@@ -491,12 +491,13 @@
                first = nodep->children;
        }
 
+       ALLOC_ZVAL(*retval);
+
        if (!first) {
-               return FAILURE;
+               ZVAL_NULL(*retval);
+               return SUCCESS;
        }
 
-       ALLOC_ZVAL(*retval);
-
        if (NULL == (*retval = php_dom_create_object(first, &ret, NULL, 
*retval, obj TSRMLS_CC))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create 
required DOM object");
                return FAILURE;
@@ -527,12 +528,13 @@
                last = nodep->last;
        }
 
+       ALLOC_ZVAL(*retval);
+
        if (!last) {
-               return FAILURE;
+               ZVAL_NULL(*retval);
+               return SUCCESS;
        }
 
-       ALLOC_ZVAL(*retval);
-
        if (NULL == (*retval = php_dom_create_object(last, &ret, NULL, *retval, 
obj TSRMLS_CC))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create 
required DOM object");
                return FAILURE;
@@ -559,13 +561,14 @@
                return FAILURE;
        }
 
+       ALLOC_ZVAL(*retval);
+
        prevsib = nodep->prev;
        if (!prevsib) {
-               return FAILURE;
+               ZVAL_NULL(*retval);
+               return SUCCESS;
        }
 
-       ALLOC_ZVAL(*retval);
-
        if (NULL == (*retval = php_dom_create_object(prevsib, &ret, NULL, 
*retval, obj TSRMLS_CC))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create 
required DOM object");
                return FAILURE;
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/bug47430.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/dom/tests/bug47430.phpt
diff -u /dev/null php-src/ext/dom/tests/bug47430.phpt:1.2
--- /dev/null   Fri Mar 13 13:43:57 2009
+++ php-src/ext/dom/tests/bug47430.phpt Fri Mar 13 13:43:57 2009
@@ -0,0 +1,30 @@
+--TEST--
+Bug #47430 (Errors after writing to nodeValue parameter of an absent 
previousSibling).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php 
+$xml = '<?xml
+version="1.0"?><html><p><i>Hello</i></p><p><i>World!</i></p></html>';
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+
+$elements = $dom->getElementsByTagName('i');
+foreach ($elements as $i) {
+  $i->previousSibling->nodeValue = '';
+}
+
+$arr = array();
+$arr[0] = 'Value';
+
+print_r($arr);
+
+?>
+--EXPECTF--
+Strict Standards: Creating default object from empty value in %s on line %d
+
+Strict Standards: Creating default object from empty value in %s on line %d
+Array
+(
+    [0] => Value
+)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to