From 734c47bfd06cae393c28d7a142856273d5323e75 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 11 Mar 2020 18:29:40 +0100 Subject: [PATCH] Fix #79199: curl_copy_handle() memory leak We must not increase the refcount of the resource; we only have to make sure that the actual CURL handle is not freed prematurely, but this is already catered to in `_php_setup_easy_copy_handlers()`. --- ext/curl/interface.c | 2 -- ext/curl/tests/bug79199.phpt | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 ext/curl/tests/bug79199.phpt diff --git a/ext/curl/interface.c b/ext/curl/interface.c index f6707310f49c2..630d3b0a89664 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2167,8 +2167,6 @@ PHP_FUNCTION(curl_copy_handle) _php_setup_easy_copy_handlers(dupch, ch); - Z_ADDREF_P(zid); - ZVAL_RES(return_value, zend_register_resource(dupch, le_curl)); dupch->res = Z_RES_P(return_value); } diff --git a/ext/curl/tests/bug79199.phpt b/ext/curl/tests/bug79199.phpt new file mode 100644 index 0000000000000..b56f22614fe6b --- /dev/null +++ b/ext/curl/tests/bug79199.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #79199 (curl_copy_handle() memory leak) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +okay