From 04323955c1f7724e54d9d70744c28860b565d9a4 Mon Sep 17 00:00:00 2001
From: Niels Dossche <7771979+ndossche@users.noreply.github.com>
Date: Tue, 4 Nov 2025 19:59:38 +0100
Subject: [PATCH 1/2] pgsql: Fix memory leak when object init fails (#20387)
The return value is already overwritten by this point so we do have to
clean up the old return value (i.e. dataset) after all.
---
ext/pgsql/pgsql.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 241dc214d8e..96a3cc7e707 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -1875,6 +1875,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
ZVAL_COPY_VALUE(&dataset, return_value);
zend_result obj_initialized = object_init_ex(return_value, ce);
if (UNEXPECTED(obj_initialized == FAILURE)) {
+ zval_ptr_dtor(&dataset);
RETURN_THROWS();
}
if (!ce->default_properties_count && !ce->__set) {
From fcc159b4f623127b054e433d957060835f73c743 Mon Sep 17 00:00:00 2001
From: Niels Dossche <7771979+ndossche@users.noreply.github.com>
Date: Mon, 3 Nov 2025 21:26:14 +0100
Subject: [PATCH 2/2] Fix GH-20374: PHP with tidy and custom-tags
Both enums and integers map to TidyInteger, however, in the TidyInteger
case we always used zval_get_long(). So for a non-numeric string, this
would get turned into 0. 0 is the first enum value in that case, so the
wrong enum value could be selected.
To solve this, add special handling for strings and (stringable) objects
such that we can explicitly check for numeric strings, and if they're
not, handle them as normal strings instead of as 0.
Closes GH-20387.
---
NEWS | 2 +
ext/tidy/tests/gh20374.phpt | 169 ++++++++++++++++++++++++++++++++++++
ext/tidy/tidy.c | 35 +++++++-
3 files changed, 202 insertions(+), 4 deletions(-)
create mode 100644 ext/tidy/tests/gh20374.phpt
diff --git a/NEWS b/NEWS
index 016342ca97d..7cf9b1dde34 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.3.29
+- Tidy:
+ . Fixed bug GH-20374 (PHP with tidy and custom-tags). (ndossche)
20 Nov 2025, PHP 8.3.28
diff --git a/ext/tidy/tests/gh20374.phpt b/ext/tidy/tests/gh20374.phpt
new file mode 100644
index 00000000000..b17706f7a27
--- /dev/null
+++ b/ext/tidy/tests/gh20374.phpt
@@ -0,0 +1,169 @@
+--TEST--
+GH-20374 (PHP with tidy and custom-tags)
+--EXTENSIONS--
+tidy
+--CREDITS--
+franck-paul
+--FILE--
+ret;
+ }
+}
+
+class MyThrowingStringable {
+ public function __toString(): string {
+ throw new Error('no');
+ }
+}
+
+$values = [
+ 'string blocklevel' => 'blocklevel',
+ 'int' => 1,
+ 'double overflow' => (string) (2.0**80.0),
+ 'numeric string int 1' => '1',
+ 'numeric string double 1.0' => '1.0',
+ 'false' => false,
+ 'true' => true,
+ 'NAN' => NAN,
+ 'INF' => INF,
+ 'object with numeric string int 0' => new MyStringable('0'),
+ 'object with string blocklevel' => new MyStringable('blocklevel'),
+ 'object with string empty' => new MyStringable('empty'),
+ 'object with exception' => new MyThrowingStringable,
+];
+
+foreach ($values as $key => $value) {
+ echo "--- $key ---\n";
+ $str = '