From 37ce67f27699bff7b5a57dc58a95daadd14f5587 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 21 Feb 2026 03:42:36 +0000 Subject: [PATCH] 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 --- NEWS | 2 ++ ext/pcntl/pcntl.c | 1 + 2 files changed, 3 insertions(+) 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(); }