Skip to content

Commit 37ce67f

Browse files
committed
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
1 parent e2a5909 commit 37ce67f

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ PHP NEWS
4444
- PCNTL:
4545
. Fixed pcntl_setns() internal errors handling regarding errnos.
4646
(David Carlier)
47+
. Fixed cpuset leak in pcntl_setcpuaffinity on out-of-range CPU ID
48+
on NetBSD/Solaris platforms. (David Carlier)
4749

4850
- PDO_PGSQL:
4951
. Fixed bug GH-21055 (connection attribute status typo for GSS negotiation).

ext/pcntl/pcntl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
17341734

17351735
if (cpu < 0 || cpu >= maxcpus) {
17361736
zend_argument_value_error(2, "cpu id must be between 0 and " ZEND_ULONG_FMT " (" ZEND_LONG_FMT ")", maxcpus, cpu);
1737+
PCNTL_CPU_DESTROY(mask);
17371738
RETURN_THROWS();
17381739
}
17391740

0 commit comments

Comments
 (0)