[php-src] PR #25794: Fix fd leak in compress.zlib:// when gzdopen() fails

From: Date: Thu, 26 Nov 2026 16:26:44 +0000
Subject: [php-src] PR #25794: Fix fd leak in compress.zlib:// when gzdopen() fails
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41064@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25794 Author: lacatoire php_stream_gzopen() hands dup(fd) to gzdopen(). When gzdopen() rejects the mode (touch(), gzopen($f, 'c'), fopen(..., 'x') on compress.zlib://), the failure path closes the inner stream but never the duplicated descriptor, so each failed open leaks one fd. This closes it. ### To reproduce ```php <?php $n = fn() => count(scandir('/proc/self/fd')); $before = $n(); for ($i = 0; $i < 50; $i++) @touch('compress.zlib:///tmp/zx'); echo $before, ' -> ', $n(), "\n"; ``` Before (PHP 8.4.28): ``` 7 -> 57 ``` After: ``` 7 -> 7 ```

« previous php.git-pulls (#41064) next »