From f39c07a3bbe52cc1e497eed70e0d7f7d70113fed Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 19 Apr 2025 16:01:34 +0200 Subject: [PATCH] DOM/XPath: Use RETURN_NEW_STR These strings are newly allocated and can't be interned, so we can use RETURN_NEW_STR. --- ext/dom/xpath.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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)); } } /* }}} */