mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02: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
1 changed files with 7 additions and 33 deletions
|
@ -1830,13 +1830,13 @@ PHP_FUNCTION(simplexml_load_file)
|
||||||
char *filename;
|
char *filename;
|
||||||
int filename_len;
|
int filename_len;
|
||||||
xmlDocPtr docp;
|
xmlDocPtr docp;
|
||||||
char *classname = NULL, *ns = NULL;
|
char *ns = NULL;
|
||||||
int classname_len = 0, ns_len = 0;
|
int ns_len = 0;
|
||||||
long options = 0;
|
long options = 0;
|
||||||
zend_class_entry *ce= sxe_class_entry;
|
zend_class_entry *ce= sxe_class_entry;
|
||||||
zend_bool isprefix = 0;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1846,14 +1846,6 @@ PHP_FUNCTION(simplexml_load_file)
|
||||||
RETURN_FALSE;
|
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 = php_sxe_object_new(ce TSRMLS_CC);
|
||||||
sxe->iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
|
sxe->iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
|
||||||
sxe->iter.isprefix = isprefix;
|
sxe->iter.isprefix = isprefix;
|
||||||
|
@ -1873,13 +1865,13 @@ PHP_FUNCTION(simplexml_load_string)
|
||||||
char *data;
|
char *data;
|
||||||
int data_len;
|
int data_len;
|
||||||
xmlDocPtr docp;
|
xmlDocPtr docp;
|
||||||
char *classname = NULL, *ns = NULL;
|
char *ns = NULL;
|
||||||
int classname_len = 0, ns_len = 0;
|
int ns_len = 0;
|
||||||
long options = 0;
|
long options = 0;
|
||||||
zend_class_entry *ce= sxe_class_entry;
|
zend_class_entry *ce= sxe_class_entry;
|
||||||
zend_bool isprefix = 0;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1889,14 +1881,6 @@ PHP_FUNCTION(simplexml_load_string)
|
||||||
RETURN_FALSE;
|
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 = php_sxe_object_new(ce TSRMLS_CC);
|
||||||
sxe->iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
|
sxe->iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
|
||||||
sxe->iter.isprefix = isprefix;
|
sxe->iter.isprefix = isprefix;
|
||||||
|
@ -2144,11 +2128,9 @@ PHP_FUNCTION(simplexml_import_dom)
|
||||||
zval *node;
|
zval *node;
|
||||||
php_libxml_node_object *object;
|
php_libxml_node_object *object;
|
||||||
xmlNodePtr nodep = NULL;
|
xmlNodePtr nodep = NULL;
|
||||||
char *classname = "";
|
|
||||||
int classname_len = 0;
|
|
||||||
zend_class_entry *ce= sxe_class_entry;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2167,14 +2149,6 @@ PHP_FUNCTION(simplexml_import_dom)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodep && nodep->type == XML_ELEMENT_NODE) {
|
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 = php_sxe_object_new(ce TSRMLS_CC);
|
||||||
sxe->document = object->document;
|
sxe->document = object->document;
|
||||||
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, nodep->doc TSRMLS_CC);
|
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, nodep->doc TSRMLS_CC);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue