Skip to content

Commit a182f0f

Browse files
committed
curl: Fix segmentation fault with libcurl 7.29.0
1 parent 404b4c8 commit a182f0f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

ext/curl/multi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,18 @@ static void curl_multi_free_obj(zend_object *object)
565565
}
566566
}
567567

568+
#if LIBCURL_VERSION_NUM < 0x071e00 /* 7.30.0 */
569+
/* In 7.29.0 curl_multi_cleanup segfaults if there no handles have been
570+
* added. To avoid this, just add and then remove a dummy handle. */
571+
CURL *tmp_cp = curl_easy_init();
572+
if (tmp_cp) {
573+
if (curl_multi_add_handle(mh->multi, tmp_cp) == CURLM_OK) {
574+
curl_multi_remove_handle(mh->multi, tmp_cp);
575+
}
576+
curl_easy_cleanup(tmp_cp);
577+
}
578+
#endif
579+
568580
curl_multi_cleanup(mh->multi);
569581
zend_llist_clean(&mh->easyh);
570582
if (mh->handlers.server_push) {

0 commit comments

Comments
 (0)