Skip to content

Commit 564db38

Browse files
committed
Fixed build with high version libcurl
1 parent c5e63f8 commit 564db38

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

ext/curl/interface.c

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,10 +1349,6 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
13491349
zend_fcall_info fci;
13501350
TSRMLS_FETCH_FROM_CTX(ch->thread_ctx);
13511351

1352-
MAKE_STD_ZVAL(zhandle);
1353-
MAKE_STD_ZVAL(zpattern);
1354-
MAKE_STD_ZVAL(zstring);
1355-
13561352
ZVAL_RES(&argv[0], ch->res);
13571353
Z_ADDREF(argv[0]);
13581354
ZVAL_STRING(&argv[1], pattern);
@@ -1649,15 +1645,15 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
16491645
*/
16501646
static void curl_free_string(void **string)
16511647
{
1652-
efree(*string);
1648+
efree((char *)*string);
16531649
}
16541650
/* }}} */
16551651

16561652
/* {{{ curl_free_post
16571653
*/
16581654
static void curl_free_post(void **post)
16591655
{
1660-
curl_formfree((struct HttpPost *) *post);
1656+
curl_formfree((struct HttpPost *)*post);
16611657
}
16621658
/* }}} */
16631659

@@ -1713,29 +1709,31 @@ PHP_FUNCTION(curl_version)
17131709

17141710
/* {{{ alloc_curl_handle
17151711
*/
1716-
static void alloc_curl_handle(php_curl **ch)
1712+
static php_curl *alloc_curl_handle()
17171713
{
1718-
*ch = ecalloc(1, sizeof(php_curl));
1719-
(*ch)->to_free = ecalloc(1, sizeof(struct _php_curl_free));
1720-
(*ch)->handlers = ecalloc(1, sizeof(php_curl_handlers));
1721-
(*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write));
1722-
(*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
1723-
(*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read));
1724-
(*ch)->handlers->progress = NULL;
1714+
php_curl *ch = ecalloc(1, sizeof(php_curl));
1715+
ch->to_free = ecalloc(1, sizeof(struct _php_curl_free));
1716+
ch->handlers = ecalloc(1, sizeof(php_curl_handlers));
1717+
ch->handlers->write = ecalloc(1, sizeof(php_curl_write));
1718+
ch->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
1719+
ch->handlers->read = ecalloc(1, sizeof(php_curl_read));
1720+
ch->handlers->progress = NULL;
17251721
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
1726-
(*ch)->handlers->fnmatch = NULL;
1722+
ch->handlers->fnmatch = NULL;
17271723
#endif
17281724

1729-
(*ch)->header.str_len = 0;
1725+
ch->header.str_len = 0;
1726+
1727+
memset(&ch->err, 0, sizeof(struct _php_curl_error));
17301728

1731-
memset(&(*ch)->err, 0, sizeof(struct _php_curl_error));
1729+
zend_llist_init(&ch->to_free->str, sizeof(char *), curl_free_string, 0);
1730+
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost), curl_free_post, 0);
1731+
ch->safe_upload = 1; /* for now, for BC reason we allow unsafe API */
17321732

1733-
zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0);
1734-
zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0);
1735-
(*ch)->safe_upload = 1; /* for now, for BC reason we allow unsafe API */
1733+
ch->to_free->slist = emalloc(sizeof(HashTable));
1734+
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
17361735

1737-
(*ch)->to_free->slist = emalloc(sizeof(HashTable));
1738-
zend_hash_init((*ch)->to_free->slist, 4, NULL, curl_free_slist, 0);
1736+
return ch;
17391737
}
17401738
/* }}} */
17411739

@@ -1867,7 +1865,7 @@ PHP_FUNCTION(curl_init)
18671865
RETURN_FALSE;
18681866
}
18691867

1870-
alloc_curl_handle(&ch);
1868+
ch = alloc_curl_handle();
18711869
TSRMLS_SET_CTX(ch->thread_ctx);
18721870

18731871
ch->cp = cp;
@@ -1910,7 +1908,7 @@ PHP_FUNCTION(curl_copy_handle)
19101908
RETURN_FALSE;
19111909
}
19121910

1913-
alloc_curl_handle(&dupch);
1911+
dupch = alloc_curl_handle();
19141912
TSRMLS_SET_CTX(dupch->thread_ctx);
19151913

19161914
dupch->cp = cp;
@@ -1970,7 +1968,7 @@ PHP_FUNCTION(curl_copy_handle)
19701968
if (ch->handlers->fnmatch) {
19711969
dupch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
19721970
if (!Z_ISUNDEF(ch->handlers->fnmatch->func_name)) {
1973-
ZVAL_COPY(&dupch->handlers->fnmatch->func_name, ch->handlers->fnmatch->func_name);
1971+
ZVAL_COPY(&dupch->handlers->fnmatch->func_name, &ch->handlers->fnmatch->func_name);
19741972
}
19751973
dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method;
19761974
curl_easy_setopt(dupch->cp, CURLOPT_FNMATCH_DATA, (void *) dupch);
@@ -2660,7 +2658,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
26602658
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
26612659
case CURLOPT_POSTREDIR:
26622660
convert_to_long_ex(zvalue);
2663-
error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL);
2661+
error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_P(zvalue) & CURL_REDIR_POST_ALL);
26642662
break;
26652663
#endif
26662664

@@ -3169,7 +3167,7 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
31693167
curl_easy_cleanup(ch->cp);
31703168

31713169
/* cURL destructors should be invoked only by last curl handle */
3172-
if (Z_REFCOUNTED(ch->clone) && Z_REFCOUNT(ch->clone) <= 1) {
3170+
if (Z_ISUNDEF(ch->clone)) {
31733171
zend_llist_clean(&ch->to_free->str);
31743172
zend_llist_clean(&ch->to_free->post);
31753173
zend_hash_destroy(ch->to_free->slist);

ext/curl/multi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ PHP_FUNCTION(curl_multi_exec)
204204
}
205205

206206
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
207+
ZVAL_DEREF(z_still_running);
207208

208209
{
209210
zend_llist_position pos;

0 commit comments

Comments
 (0)