Skip to content

Commit 2d029ef

Browse files
authored
Avoid duplicating the filename string when profiling in XSL (#15010)
1 parent a59103f commit 2d029ef

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

ext/xsl/php_xsl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct xsl_object {
6060
zend_long securityPrefs;
6161
php_dom_xpath_callbacks xpath_callbacks;
6262
php_libxml_node_object *doc;
63-
char *profiling;
63+
zend_string *profiling;
6464
zend_object std;
6565
} xsl_object;
6666

ext/xsl/xsltprocessor.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
317317
}
318318

319319
if (intern->profiling) {
320-
if (php_check_open_basedir(intern->profiling)) {
320+
if (php_check_open_basedir(ZSTR_VAL(intern->profiling))) {
321321
f = NULL;
322322
} else {
323-
f = VCWD_FOPEN(intern->profiling, "w");
323+
f = VCWD_FOPEN(ZSTR_VAL(intern->profiling), "w");
324324
}
325325
} else {
326326
f = NULL;
@@ -730,19 +730,18 @@ PHP_METHOD(XSLTProcessor, setProfiling)
730730
{
731731
zval *id = ZEND_THIS;
732732
xsl_object *intern;
733-
char *filename = NULL;
734-
size_t filename_len;
733+
zend_string *filename = NULL;
735734

736-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p!", &filename, &filename_len) == FAILURE) {
735+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P!", &filename) == FAILURE) {
737736
RETURN_THROWS();
738737
}
739738

740739
intern = Z_XSL_P(id);
741740
if (intern->profiling) {
742-
efree(intern->profiling);
741+
zend_string_release(intern->profiling);
743742
}
744743
if (filename != NULL) {
745-
intern->profiling = estrndup(filename, filename_len);
744+
intern->profiling = zend_string_copy(filename);
746745
} else {
747746
intern->profiling = NULL;
748747
}

0 commit comments

Comments
 (0)