From: Marcus Boerger Date: Tue, 23 May 2006 21:37:17 +0000 (+0000) Subject: - Fix SEGV in case class to generate is not derived from SimpleXMLElement X-Git-Tag: BEFORE_NEW_OUTPUT_API~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ccd2bc0005a5b284bf75812cee52a401b971fb6c;p=php - Fix SEGV in case class to generate is not derived from SimpleXMLElement by issueing an error --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 66572b0632..5796f0745c 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1830,13 +1830,13 @@ PHP_FUNCTION(simplexml_load_file) 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 @@ PHP_FUNCTION(simplexml_load_file) 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 @@ PHP_FUNCTION(simplexml_load_string) 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 @@ PHP_FUNCTION(simplexml_load_string) 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 @@ PHP_FUNCTION(simplexml_import_dom) 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 @@ PHP_FUNCTION(simplexml_import_dom) } 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);