Skip to content

ext/curl: Free the pushed handle when the push callback denies or throws - #23850

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:promote/curl-push-deny-leak
Open

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:promote/curl-push-deny-leak

Conversation

@iliaal

@iliaal iliaal commented Sep 22, 2026

Copy link
Copy Markdown
Member

When the callback denies the push, or throws and leaves the return value undefined, libcurl destroys the easy handle itself, but the wrapper kept a stale ch->cp and never released the CurlHandle it had just created, so each denied push leaked one wrapper and permanently bumped the parent's clone counter. The per-instance teardown moves out of curl_free_obj() into _php_curl_free_instance(), reused for the denied handle with ch->cp cleared first so the object dtor takes its constructor-failure exit rather than cleaning up twice. The new test needs Caddy, so it only runs in the lanes that have it.

When the callback denies the push, or throws and leaves the return value
undefined, libcurl destroys the easy handle itself, but the wrapper kept a
stale ch->cp and never released the CurlHandle it had just created, so each
denied push leaked one wrapper and permanently bumped the parent's clone
counter. Factor the per-instance teardown out of curl_free_obj() into
_php_curl_free_instance() and reuse it for the denied handle, clearing
ch->cp first so the object dtor takes its constructor-failure exit instead
of cleaning up twice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant