Skip to content

Commit f4c105d

Browse files
committed
Fixed post data (long type cast matters here :<)
1 parent 763cee6 commit f4c105d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

ext/curl/interface.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@ static php_curl *alloc_curl_handle()
17211721
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
17221722
ch->handlers->fnmatch = NULL;
17231723
#endif
1724+
ch->clone = 1;
17241725

17251726
memset(&ch->err, 0, sizeof(struct _php_curl_error));
17261727

@@ -2462,8 +2463,8 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
24622463
HashTable *postfields;
24632464
zend_string *string_key;
24642465
ulong num_key;
2465-
struct HttpPost *first = NULL;
2466-
struct HttpPost *last = NULL;
2466+
struct HttpPost *first = NULL;
2467+
struct HttpPost *last = NULL;
24672468

24682469
postfields = HASH_OF(zvalue);
24692470
if (!postfields) {
@@ -2565,15 +2566,16 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
25652566
} else {
25662567
error = curl_formadd(&first, &last,
25672568
CURLFORM_COPYNAME, string_key->val,
2568-
CURLFORM_NAMELENGTH, string_key->len,
2569+
CURLFORM_NAMELENGTH, (long)string_key->len,
25692570
CURLFORM_COPYCONTENTS, postval,
2570-
CURLFORM_CONTENTSLENGTH, Z_STRLEN_P(current),
2571+
CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_P(current),
25712572
CURLFORM_END);
25722573
}
25732574

25742575
if (numeric_key) {
25752576
STR_RELEASE(string_key);
25762577
}
2578+
25772579
} ZEND_HASH_FOREACH_END();
25782580

25792581
SAVE_CURL_ERROR(ch, error);
@@ -2583,9 +2585,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
25832585

25842586
if (ch->clone == 0) {
25852587
zend_llist_clean(&ch->to_free->post);
2586-
} else {
2587-
--ch->clone;
2588-
}
2588+
}
25892589
zend_llist_add_element(&ch->to_free->post, &first);
25902590
error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first);
25912591
} else {
@@ -3136,7 +3136,7 @@ PHP_FUNCTION(curl_close)
31363136
return;
31373137
}
31383138

3139-
zend_list_close(Z_RES_P(zid));
3139+
zend_list_delete(Z_RES_P(zid));
31403140
}
31413141
/* }}} */
31423142

@@ -3167,14 +3167,12 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
31673167
curl_easy_cleanup(ch->cp);
31683168

31693169
/* cURL destructors should be invoked only by last curl handle */
3170-
if (ch->clone == 0) {
3170+
if (--ch->clone == 0) {
31713171
zend_llist_clean(&ch->to_free->str);
31723172
zend_llist_clean(&ch->to_free->post);
31733173
zend_hash_destroy(ch->to_free->slist);
31743174
efree(ch->to_free->slist);
31753175
efree(ch->to_free);
3176-
} else {
3177-
--ch->clone;
31783176
}
31793177

31803178
smart_str_free(&ch->handlers->write->buf);

0 commit comments

Comments
 (0)