helly           Tue May 23 21:37:18 2006 UTC

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  - Fix SEGV in case class to generate is not derived from SimpleXMLElement
    by issueing an error
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.207&r2=1.208&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.207 
php-src/ext/simplexml/simplexml.c:1.208
--- php-src/ext/simplexml/simplexml.c:1.207     Wed May 17 00:07:05 2006
+++ php-src/ext/simplexml/simplexml.c   Tue May 23 21:37:17 2006
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.207 2006/05/17 00:07:05 helly Exp $ */
+/* $Id: simplexml.c,v 1.208 2006/05/23 21:37:17 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1830,13 +1830,13 @@
        char           *filename;
        int             filename_len;
        xmlDocPtr       docp;
-       char           *classname = NULL, *ns = NULL;
-       int             classname_len = 0, ns_len = 0;
+       char           *ns = NULL;
+       int             ns_len = 0;
        long            options = 0;
        zend_class_entry *ce= sxe_class_entry;
        zend_bool       isprefix = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slsb", 
&filename, &filename_len, &classname, &classname_len, &options, &ns, &ns_len, 
&isprefix) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Clsb", 
&filename, &filename_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) {
                return;
        }
 
@@ -1846,14 +1846,6 @@
                RETURN_FALSE;
        }
 
-       if (classname_len) {
-               zend_class_entry **pce;
-               if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) 
== FAILURE) {
-                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s 
does not exist", classname);
-               }
-               ce = *pce;
-       }
-
        sxe = php_sxe_object_new(ce TSRMLS_CC);
        sxe->iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
        sxe->iter.isprefix = isprefix;
@@ -1873,13 +1865,13 @@
        char           *data;
        int             data_len;
        xmlDocPtr       docp;
-       char           *classname = NULL, *ns = NULL;
-       int             classname_len = 0, ns_len = 0;
+       char           *ns = NULL;
+       int             ns_len = 0;
        long            options = 0;
        zend_class_entry *ce= sxe_class_entry;
        zend_bool       isprefix = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slsb", &data, 
&data_len, &classname, &classname_len, &options, &ns, &ns_len, &isprefix) == 
FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Clsb", &data, 
&data_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) {
                return;
        }
 
@@ -1889,14 +1881,6 @@
                RETURN_FALSE;
        }
 
-       if (classname_len) {
-               zend_class_entry **pce;
-               if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) 
== FAILURE) {
-                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s 
does not exist", classname);
-               }
-               ce = *pce;
-       }
-
        sxe = php_sxe_object_new(ce TSRMLS_CC);
        sxe->iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
        sxe->iter.isprefix = isprefix;
@@ -2144,11 +2128,9 @@
        zval *node;
        php_libxml_node_object *object;
        xmlNodePtr              nodep = NULL;
-       char           *classname = "";
-       int             classname_len = 0;
        zend_class_entry *ce= sxe_class_entry;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|s", &node, 
&classname, &classname_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|C", &node, &ce) 
== FAILURE) {
                return;
        }
 
@@ -2167,14 +2149,6 @@
        }
 
        if (nodep && nodep->type == XML_ELEMENT_NODE) {
-               if (classname_len) {
-                       zend_class_entry **pce;
-                       if (zend_lookup_class(classname, classname_len, &pce 
TSRMLS_CC) == FAILURE) {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, 
"Class %s does not exist", classname);
-                       }
-                       ce = *pce;
-               }
-
                sxe = php_sxe_object_new(ce TSRMLS_CC);
                sxe->document = object->document;
                php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, 
nodep->doc TSRMLS_CC);
@@ -2279,7 +2253,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.207 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.208 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");

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

Reply via email to