Skip to content

Avoid duplicating the filename string when profiling in XSL #15010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/xsl/php_xsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef struct xsl_object {
zend_long securityPrefs;
php_dom_xpath_callbacks xpath_callbacks;
php_libxml_node_object *doc;
char *profiling;
zend_string *profiling;
zend_object std;
} xsl_object;

Expand Down
13 changes: 6 additions & 7 deletions ext/xsl/xsltprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
}

if (intern->profiling) {
if (php_check_open_basedir(intern->profiling)) {
if (php_check_open_basedir(ZSTR_VAL(intern->profiling))) {
f = NULL;
} else {
f = VCWD_FOPEN(intern->profiling, "w");
f = VCWD_FOPEN(ZSTR_VAL(intern->profiling), "w");
}
} else {
f = NULL;
Expand Down Expand Up @@ -727,19 +727,18 @@ PHP_METHOD(XSLTProcessor, setProfiling)
{
zval *id = ZEND_THIS;
xsl_object *intern;
char *filename = NULL;
size_t filename_len;
zend_string *filename = NULL;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "p!", &filename, &filename_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P!", &filename) == FAILURE) {
RETURN_THROWS();
}

intern = Z_XSL_P(id);
if (intern->profiling) {
efree(intern->profiling);
zend_string_release(intern->profiling);
}
if (filename != NULL) {
intern->profiling = estrndup(filename, filename_len);
intern->profiling = zend_string_copy(filename);
} else {
intern->profiling = NULL;
}
Expand Down
Loading