mirror of
https://github.com/php/php-src.git
synced 2025-01-10 21:14:37 +08:00
- Fix SEGV in case class to generate is not derived from SimpleXMLElement
by issueing an error
This commit is contained in:
parent
9ac660b72e
commit
ccd2bc0005
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user