Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4b6c465

Browse files
Implement curl_copy_handle in terms of object cloning (#19841)
This prevents the implementations from going out of sync, causing bugs like #19813.
1 parent 025ac98 commit 4b6c465

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

‎ext/curl/interface.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,37 +1544,23 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
15441544
/* {{{ Copy a cURL handle along with all of it's preferences */
15451545
PHP_FUNCTION(curl_copy_handle)
15461546
{
1547-
php_curl *ch;
1548-
CURL *cp;
15491547
zval *zid;
1550-
php_curl *dupch;
1551-
zval *postfields;
15521548

15531549
ZEND_PARSE_PARAMETERS_START(1,1)
15541550
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
15551551
ZEND_PARSE_PARAMETERS_END();
15561552

1557-
ch = Z_CURL_P(zid);
1558-
1559-
cp = curl_easy_duphandle(ch->cp);
1560-
if (!cp) {
1553+
zend_object *new_object = Z_OBJ_P(zid)->handlers->clone_obj(Z_OBJ_P(zid));
1554+
if (EG(exception)) {
1555+
if (new_object != NULL) {
1556+
OBJ_RELEASE(new_object);
1557+
}
1558+
zend_clear_exception();
15611559
php_error_docref(NULL, E_WARNING, "Cannot duplicate cURL handle");
15621560
RETURN_FALSE;
15631561
}
15641562

1565-
dupch = init_curl_handle_into_zval(return_value);
1566-
dupch->cp = cp;
1567-
1568-
_php_setup_easy_copy_handlers(dupch, ch);
1569-
1570-
postfields = &ch->postfields;
1571-
if (Z_TYPE_P(postfields) != IS_UNDEF) {
1572-
if (build_mime_structure_from_hash(dupch, postfields) == FAILURE) {
1573-
zval_ptr_dtor(return_value);
1574-
php_error_docref(NULL, E_WARNING, "Cannot rebuild mime structure");
1575-
RETURN_FALSE;
1576-
}
1577-
}
1563+
RETURN_OBJ(new_object);
15781564
}
15791565
/* }}} */
15801566

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /