[php-src] PR #24513: Fix GH-24508: HTTP wrapper leaks dechunk filter when header parsing fails
| From: | bercedev | Date: | Wed, 21 Oct 2026 21:39:00 +0000 |
| Subject: | [php-src] PR #24513: Fix GH-24508: HTTP wrapper leaks dechunk filter when header parsing fails | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39681@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24513
Author: bercedev
Fixes GH-24508
When the response carries
Transfer-Encoding: chunked, the header parser creates the
dechunk filter in header_info.transfer_encoding. At out: it
is only handed to the stream (php_stream_filter_append()) when stream !=
NULL. If a later header line sets header_info.error, the stream is closed before
out: and the filter is never freed. The out: block now frees it in the
else branch, where no stream will own it. The redirect path already frees it on its own
(and sets it to NULL), so it isn't affected.
The new ext/standard/tests/http/gh24508.phpt sends Transfer-Encoding:
chunked followed by a header line without a colon. On a debug build (--enable-debug
--enable-pcntl --enable-posix) of PHP-8.4 without the fix it fails with:
```
ext/standard/filters.c(1891) : Freeing 0x... (16 bytes), script=.../gh24508.php
main/streams/filter.c(269) : Freeing 0x... (80 bytes), script=.../gh24508.php
```
With the fix it passes, and ext/standard/tests/http/ gives 71 passed, 14 skipped, 0
failed.
This touches the same file as #24512 (GH-24509), in a different place, so the two don't
conflict.