Commit 37ce67f2769 for php.net
commit 37ce67f27699bff7b5a57dc58a95daadd14f5587
Author: David Carlier <devnexen@gmail.com>
Date: Sat Feb 21 03:42:36 2026 +0000
ext/pcntl: Fix cpuset leak in pcntl_setcpuaffinity on out-of-range CPU ID
Add missing PCNTL_CPU_DESTROY(mask) call before RETURN_THROWS() when
the cpu id is out of range, matching the cleanup on other error paths.
close GH-21268
diff --git a/NEWS b/NEWS
index 8a0b3880255..d31c2d16042 100644
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,8 @@ PHP NEWS
- PCNTL:
. Fixed pcntl_setns() internal errors handling regarding errnos.
(David Carlier)
+ . Fixed cpuset leak in pcntl_setcpuaffinity on out-of-range CPU ID
+ on NetBSD/Solaris platforms. (David Carlier)
- PDO_PGSQL:
. Fixed bug GH-21055 (connection attribute status typo for GSS negotiation).
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 853215e39f9..e3b4a9c4c69 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -1734,6 +1734,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
if (cpu < 0 || cpu >= maxcpus) {
zend_argument_value_error(2, "cpu id must be between 0 and " ZEND_ULONG_FMT " (" ZEND_LONG_FMT ")", maxcpus, cpu);
+ PCNTL_CPU_DESTROY(mask);
RETURN_THROWS();
}