Commit f39c07a3bbe for php.net
commit f39c07a3bbe52cc1e497eed70e0d7f7d70113fed
Author: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Date: Sat Apr 19 16:01:34 2025 +0200
DOM/XPath: Use RETURN_NEW_STR
These strings are newly allocated and can't be interned, so we can use
RETURN_NEW_STR.
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index de7ce22ed12..8707af1fa94 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -499,14 +499,14 @@ PHP_METHOD(DOMXPath, quote) {
memcpy(ZSTR_VAL(output) + 1, input, input_len);
ZSTR_VAL(output)[input_len + 1] = '\'';
ZSTR_VAL(output)[input_len + 2] = '\0';
- RETURN_STR(output);
+ RETURN_NEW_STR(output);
} else if (memchr(input, '"', input_len) == NULL) {
zend_string *const output = zend_string_safe_alloc(1, input_len, 2, false);
ZSTR_VAL(output)[0] = '"';
memcpy(ZSTR_VAL(output) + 1, input, input_len);
ZSTR_VAL(output)[input_len + 1] = '"';
ZSTR_VAL(output)[input_len + 2] = '\0';
- RETURN_STR(output);
+ RETURN_NEW_STR(output);
} else {
smart_str output = {0};
// need to use the concat() trick published by Robert Rossney at https://stackoverflow.com/a/1352556/1067003
@@ -528,7 +528,7 @@ PHP_METHOD(DOMXPath, quote) {
}
ZEND_ASSERT(ptr == end);
ZSTR_VAL(output.s)[ZSTR_LEN(output.s) - 1] = ')';
- RETURN_STR(smart_str_extract(&output));
+ RETURN_NEW_STR(smart_str_extract(&output));
}
}
/* }}} */