rrichards               Tue Jul  1 15:28:30 2003 EDT

  Modified files:              
    /php-src/ext/dom    document.c 
  Log:
  fix load() and loadxml() when used with uninstantiated object
  
Index: php-src/ext/dom/document.c
diff -u php-src/ext/dom/document.c:1.7 php-src/ext/dom/document.c:1.8
--- php-src/ext/dom/document.c:1.7      Sun Jun 15 15:58:42 2003
+++ php-src/ext/dom/document.c  Tue Jul  1 15:28:30 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: document.c,v 1.7 2003/06/15 19:58:42 rrichards Exp $ */
+/* $Id: document.c,v 1.8 2003/07/01 19:28:30 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -997,11 +997,11 @@
 */
 PHP_FUNCTION(dom_document_load)
 {
-       zval *id;
+       zval *id, *rv = NULL;
        xmlDoc *docp = NULL, *newdoc;
        dom_object *intern;
        char *source;
-       int source_len, refcount;
+       int source_len, refcount, ret;
 
        id = getThis();
        
@@ -1009,27 +1009,31 @@
                return;
        }
 
-       newdoc = docp = xmlParseFile(source);
+       newdoc = xmlParseFile(source);
 
        if (!newdoc)
                RETURN_FALSE;
 
-       intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
-       if (intern != NULL) {
-               docp = (xmlDocPtr)intern->ptr;
-               if (docp != NULL) {
-                       refcount = decrement_document_reference(intern TSRMLS_CC);
-                       if (refcount != 0) {
-                               docp->_private = NULL;
+       if (id != NULL) {
+               intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
+               if (intern != NULL) {
+                       docp = (xmlDocPtr)intern->ptr;
+                       if (docp != NULL) {
+                               refcount = decrement_document_reference(intern 
TSRMLS_CC);
+                               if (refcount != 0) {
+                                       docp->_private = NULL;
+                               }
                        }
+                       intern->document = NULL;
+                       increment_document_reference(intern, newdoc TSRMLS_CC);
                }
-               intern->document = NULL;
-               increment_document_reference(intern, newdoc TSRMLS_CC);
-       }
 
-       php_dom_set_object(intern, newdoc TSRMLS_CC);
+               php_dom_set_object(intern, newdoc TSRMLS_CC);
 
-       RETURN_TRUE;
+               RETURN_TRUE;
+       } else {
+               DOM_RET_OBJ(rv, (xmlNodePtr) newdoc, &ret, NULL);
+       }
 }
 /* }}} end dom_document_load */
 
@@ -1039,11 +1043,11 @@
 */
 PHP_FUNCTION(dom_document_loadxml)
 {
-       zval *id;
+       zval *id, *rv = NULL;
        xmlDoc *docp = NULL, *newdoc;
        dom_object *intern;
        char *buffer;
-       int buffer_len, refcount;
+       int buffer_len, refcount, ret;
 
        id = getThis();
        
@@ -1055,23 +1059,27 @@
        if (!newdoc)
                RETURN_FALSE;
 
-       intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
-       if (intern != NULL) {
-               docp = (xmlDocPtr)intern->ptr;
-               if (docp != NULL) {
-                       refcount = decrement_document_reference(intern TSRMLS_CC);
-                       if (refcount != 0) {
-                               docp->_private = NULL;
+       if (id != NULL) {
+               intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
+               if (intern != NULL) {
+                       docp = (xmlDocPtr)intern->ptr;
+                       if (docp != NULL) {
+                               refcount = decrement_document_reference(intern 
TSRMLS_CC);
+                               if (refcount != 0) {
+                                       docp->_private = NULL;
+                               }
+                               intern->document = NULL;
                        }
                        intern->document = NULL;
+                       increment_document_reference(intern, newdoc TSRMLS_CC);
                }
-               intern->document = NULL;
-               increment_document_reference(intern, newdoc TSRMLS_CC);
-       }
 
-       php_dom_set_object(intern, newdoc TSRMLS_CC);
+               php_dom_set_object(intern, newdoc TSRMLS_CC);
 
-       RETURN_TRUE;
+               RETURN_TRUE;
+       } else {
+               DOM_RET_OBJ(rv, (xmlNodePtr) newdoc, &ret, NULL);
+       }
 }
 /* }}} end dom_document_loadxml */
 



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

Reply via email to