]> granicus.if.org Git - php/commitdiff
ok, this is a zend bug.
authorSterling Hughes <sterling@php.net>
Mon, 9 Jun 2003 04:01:11 +0000 (04:01 +0000)
committerSterling Hughes <sterling@php.net>
Mon, 9 Jun 2003 04:01:11 +0000 (04:01 +0000)
ext/simplexml/examples/book.php
ext/simplexml/simplexml.c

index 762f855c5299a8f7f186ad8da805a558a88a4460..0416df861b4b2921d0ba0c55637794246e6be853 100644 (file)
@@ -1,6 +1,7 @@
 <?php
-$books = simplexml_load_file('book.xml')->book;
-
+$books = simplexml_load_file('book.xml');
+//var_dump($books);
+$books = $books->book;
 foreach ($books as $book) {
        echo "{$book->title} was written by {$book->author}\n";
 }
index 7eb522d7859d9d69d670bcfe2cfd7a8fff9c3d8e..83de2cc69254b5b6c07e935b039ec3c291122fe2 100644 (file)
@@ -783,13 +783,14 @@ sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC)
 
        sxe = (php_sxe_object *) object;
 
+       FREE_HASHTABLE(sxe->zo.properties);
+
        if (--sxe->document->refcount > 0) {
                return;
        }
-       
        xmlFreeDoc(sxe->document->ptr);
-       FREE_HASHTABLE(sxe->zo.properties);
-
+       efree(sxe->document);
+               
        if (sxe->xpath) {
                xmlXPathFreeContext(sxe->xpath);
        }
@@ -858,8 +859,8 @@ PHP_FUNCTION(simplexml_load_file)
 
        sxe = php_sxe_object_new(TSRMLS_C);
        sxe->document = emalloc(sizeof(simplexml_ref_obj));
-       sxe->document->refcount = 1;
        sxe->document->ptr = (void *) xmlParseFile(filename);
+       sxe->document->refcount = 1;
        if (sxe->document->ptr == NULL) {
                efree(sxe->document);
                RETURN_FALSE;
@@ -893,7 +894,7 @@ PHP_FUNCTION(simplexml_load_string)
                RETURN_FALSE;
        }
        sxe->nsmap = xmlHashCreate(10);
-               
+
        return_value->type = IS_OBJECT;
        return_value->value.obj = php_sxe_register_object(sxe TSRMLS_CC);
 }