Skip to content

Commit 8774e96

Browse files
ZhongRuoyunielsdos
authored andcommitted
Fix naming clash with libxml macro
In the macOS 26 SDK, xmlFree is defined as a macro for free. This causes issues where a same-named variable is used. Renaming the variable to should_free resolves the issue. See: $ grep -B4 -A2 -n "#define xmlFree(" "Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.sdk/usr/include/libxml/globals.h" 261-#if defined(LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS) 262-#define xmlMalloc(size) malloc(size) 263-#define xmlMallocAtomic(size) malloc(size) 264-#define xmlRealloc(ptr, size) realloc((ptr), (size)) 265:#define xmlFree(ptr) free(ptr) 266-#define xmlMemStrdup(str) strdup(str) 267-#endif Fixes: ``` In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/libxml/xmlIO.h:117, from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/libxml/parser.h:813, from /private/tmp/php-20250914-13349-uqsk5o/php-8.4.12/ext/dom/php_dom.h:29, from /private/tmp/php-20250914-13349-uqsk5o/php-8.4.12/ext/dom/attr.c:26: /private/tmp/php-20250914-13349-uqsk5o/php-8.4.12/ext/dom/attr.c: In function 'dom_compare_value': /private/tmp/php-20250914-13349-uqsk5o/php-8.4.12/ext/dom/attr.c:208:17: error: called object 'free' is not a function or function pointer 208 | xmlFree(attr_value); | ^~~~~~~ /private/tmp/php-20250914-13349-uqsk5o/php-8.4.12/ext/dom/attr.c:204:14: note: declared here 204 | bool free; | ^~~~ make: *** [ext/dom/attr.lo] Error 1 ``` Closes GH-19832. Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
1 parent 8e1df69 commit 8774e96

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ PHP NEWS
1414
of the curl_copy_handle() function to clone a CurlHandle. (timwolla)
1515
. Fix curl build failure on macOS+curl 8.16. (nielsdos)
1616

17+
- DOM:
18+
. Fix macro name clash on macOS. (Ruoyu Zhong)
19+
1720
- Opcache:
1821
. Fixed bug GH-19669 (assertion failure in zend_jit_trace_type_to_info_ex).
1922
(Arnaud)

ext/dom/attr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ PHP_METHOD(DOMAttr, isId)
201201

202202
bool dom_compare_value(const xmlAttr *attr, const xmlChar *value)
203203
{
204-
bool free;
205-
xmlChar *attr_value = php_libxml_attr_value(attr, &free);
204+
bool should_free;
205+
xmlChar *attr_value = php_libxml_attr_value(attr, &should_free);
206206
bool result = xmlStrEqual(attr_value, value);
207-
if (free) {
207+
if (should_free) {
208208
xmlFree(attr_value);
209209
}
210210
return result;

ext/dom/php_dom.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,10 +2396,10 @@ void php_dom_get_content_into_zval(const xmlNode *nodep, zval *return_value, boo
23962396
}
23972397

23982398
case XML_ATTRIBUTE_NODE: {
2399-
bool free;
2400-
xmlChar *value = php_libxml_attr_value((const xmlAttr *) nodep, &free);
2399+
bool should_free;
2400+
xmlChar *value = php_libxml_attr_value((const xmlAttr *) nodep, &should_free);
24012401
RETVAL_STRING_FAST((const char *) value);
2402-
if (free) {
2402+
if (should_free) {
24032403
xmlFree(value);
24042404
}
24052405
return;

ext/simplexml/simplexml.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,10 @@ static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node,
15291529
/* Attributes in the xmlns namespace should be treated as namespace declarations too. */
15301530
if (attr->ns && xmlStrEqual(attr->ns->href, (const xmlChar *) "http://www.w3.org/2000/xmlns/")) {
15311531
const char *prefix = attr->ns->prefix ? (const char *) attr->name : "";
1532-
bool free;
1533-
xmlChar *href = php_libxml_attr_value(attr, &free);
1532+
bool should_free;
1533+
xmlChar *href = php_libxml_attr_value(attr, &should_free);
15341534
sxe_add_namespace_name_raw(return_value, prefix, (const char *) href);
1535-
if (free) {
1535+
if (should_free) {
15361536
xmlFree(href);
15371537
}
15381538
}

0 commit comments

Comments
 (0)