@@ -1443,7 +1443,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1443
1443
postval = Z_STR_P (prop );
1444
1444
1445
1445
if (php_check_open_basedir (ZSTR_VAL (postval ))) {
1446
- return FAILURE ;
1446
+ goto out_string ;
1447
1447
}
1448
1448
1449
1449
prop = zend_read_property (curl_CURLFile_class , Z_OBJ_P (current ), "mime" , sizeof ("mime" )- 1 , 0 , & rv );
@@ -1469,15 +1469,18 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1469
1469
seekfunc = NULL ;
1470
1470
}
1471
1471
1472
+ part = curl_mime_addpart (mime );
1473
+ if (part == NULL ) {
1474
+ if (stream ) {
1475
+ php_stream_close (stream );
1476
+ }
1477
+ goto out_string ;
1478
+ }
1479
+
1472
1480
cb_arg = emalloc (sizeof * cb_arg );
1473
1481
cb_arg -> filename = zend_string_copy (postval );
1474
1482
cb_arg -> stream = stream ;
1475
1483
1476
- part = curl_mime_addpart (mime );
1477
- if (part == NULL ) {
1478
- zend_string_release_ex (string_key , 0 );
1479
- return FAILURE ;
1480
- }
1481
1484
if ((form_error = curl_mime_name (part , ZSTR_VAL (string_key ))) != CURLE_OK
1482
1485
|| (form_error = curl_mime_data_cb (part , filesize , read_cb , seekfunc , free_cb , cb_arg )) != CURLE_OK
1483
1486
|| (form_error = curl_mime_filename (part , filename ? filename : ZSTR_VAL (postval ))) != CURLE_OK
@@ -1511,8 +1514,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1511
1514
1512
1515
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "postname" , sizeof ("postname" )- 1 , 0 , & rv );
1513
1516
if (EG (exception )) {
1514
- zend_string_release_ex (string_key , 0 );
1515
- return FAILURE ;
1517
+ goto out_string ;
1516
1518
}
1517
1519
ZVAL_DEREF (prop );
1518
1520
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1521,8 +1523,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1521
1523
1522
1524
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "mime" , sizeof ("mime" )- 1 , 0 , & rv );
1523
1525
if (EG (exception )) {
1524
- zend_string_release_ex (string_key , 0 );
1525
- return FAILURE ;
1526
+ goto out_string ;
1526
1527
}
1527
1528
ZVAL_DEREF (prop );
1528
1529
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1531,8 +1532,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1531
1532
1532
1533
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "data" , sizeof ("data" )- 1 , 0 , & rv );
1533
1534
if (EG (exception )) {
1534
- zend_string_release_ex (string_key , 0 );
1535
- return FAILURE ;
1535
+ goto out_string ;
1536
1536
}
1537
1537
ZVAL_DEREF (prop );
1538
1538
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1545,8 +1545,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1545
1545
1546
1546
part = curl_mime_addpart (mime );
1547
1547
if (part == NULL ) {
1548
- zend_string_release_ex (string_key , 0 );
1549
- return FAILURE ;
1548
+ goto out_string ;
1550
1549
}
1551
1550
if ((form_error = curl_mime_name (part , ZSTR_VAL (string_key ))) != CURLE_OK
1552
1551
|| (form_error = curl_mime_data (part , ZSTR_VAL (postval ), ZSTR_LEN (postval ))) != CURLE_OK
@@ -1602,7 +1601,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1602
1601
1603
1602
SAVE_CURL_ERROR (ch , error );
1604
1603
if (error != CURLE_OK ) {
1605
- return FAILURE ;
1604
+ goto out_mime ;
1606
1605
}
1607
1606
1608
1607
if ((* ch -> clone ) == 1 ) {
@@ -1618,6 +1617,16 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1618
1617
1619
1618
SAVE_CURL_ERROR (ch , error );
1620
1619
return error == CURLE_OK ? SUCCESS : FAILURE ;
1620
+
1621
+ out_string :
1622
+ zend_string_release_ex (string_key , false);
1623
+ out_mime :
1624
+ #if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
1625
+ curl_mime_free (mime );
1626
+ #else
1627
+ curl_formfree (first );
1628
+ #endif
1629
+ return FAILURE ;
1621
1630
}
1622
1631
/* }}} */
1623
1632
0 commit comments