@@ -1436,7 +1436,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1436
1436
postval = Z_STR_P (prop );
1437
1437
1438
1438
if (php_check_open_basedir (ZSTR_VAL (postval ))) {
1439
- return FAILURE ;
1439
+ goto out_string ;
1440
1440
}
1441
1441
1442
1442
prop = zend_read_property (curl_CURLFile_class , Z_OBJ_P (current ), "mime" , sizeof ("mime" )- 1 , 0 , & rv );
@@ -1461,15 +1461,18 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1461
1461
seekfunc = NULL ;
1462
1462
}
1463
1463
1464
+ part = curl_mime_addpart (mime );
1465
+ if (part == NULL ) {
1466
+ if (stream ) {
1467
+ php_stream_close (stream );
1468
+ }
1469
+ goto out_string ;
1470
+ }
1471
+
1464
1472
cb_arg = emalloc (sizeof * cb_arg );
1465
1473
cb_arg -> filename = zend_string_copy (postval );
1466
1474
cb_arg -> stream = stream ;
1467
1475
1468
- part = curl_mime_addpart (mime );
1469
- if (part == NULL ) {
1470
- zend_string_release_ex (string_key , 0 );
1471
- return FAILURE ;
1472
- }
1473
1476
if ((form_error = curl_mime_name (part , ZSTR_VAL (string_key ))) != CURLE_OK
1474
1477
|| (form_error = curl_mime_data_cb (part , filesize , read_cb , seekfunc , free_cb , cb_arg )) != CURLE_OK
1475
1478
|| (form_error = curl_mime_filename (part , filename ? filename : ZSTR_VAL (postval ))) != CURLE_OK
@@ -1490,8 +1493,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1490
1493
1491
1494
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "postname" , sizeof ("postname" )- 1 , 0 , & rv );
1492
1495
if (EG (exception )) {
1493
- zend_string_release_ex (string_key , 0 );
1494
- return FAILURE ;
1496
+ goto out_string ;
1495
1497
}
1496
1498
ZVAL_DEREF (prop );
1497
1499
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1500,8 +1502,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1500
1502
1501
1503
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "mime" , sizeof ("mime" )- 1 , 0 , & rv );
1502
1504
if (EG (exception )) {
1503
- zend_string_release_ex (string_key , 0 );
1504
- return FAILURE ;
1505
+ goto out_string ;
1505
1506
}
1506
1507
ZVAL_DEREF (prop );
1507
1508
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1510,8 +1511,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1510
1511
1511
1512
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "data" , sizeof ("data" )- 1 , 0 , & rv );
1512
1513
if (EG (exception )) {
1513
- zend_string_release_ex (string_key , 0 );
1514
- return FAILURE ;
1514
+ goto out_string ;
1515
1515
}
1516
1516
ZVAL_DEREF (prop );
1517
1517
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1523,8 +1523,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1523
1523
1524
1524
part = curl_mime_addpart (mime );
1525
1525
if (part == NULL ) {
1526
- zend_string_release_ex (string_key , 0 );
1527
- return FAILURE ;
1526
+ goto out_string ;
1528
1527
}
1529
1528
if ((form_error = curl_mime_name (part , ZSTR_VAL (string_key ))) != CURLE_OK
1530
1529
|| (form_error = curl_mime_data (part , ZSTR_VAL (postval ), ZSTR_LEN (postval ))) != CURLE_OK
@@ -1555,7 +1554,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1555
1554
1556
1555
SAVE_CURL_ERROR (ch , error );
1557
1556
if (error != CURLE_OK ) {
1558
- return FAILURE ;
1557
+ goto out_mime ;
1559
1558
}
1560
1559
1561
1560
if ((* ch -> clone ) == 1 ) {
@@ -1566,6 +1565,12 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1566
1565
1567
1566
SAVE_CURL_ERROR (ch , error );
1568
1567
return error == CURLE_OK ? SUCCESS : FAILURE ;
1568
+
1569
+ out_string :
1570
+ zend_string_release_ex (string_key , false);
1571
+ out_mime :
1572
+ curl_mime_free (mime );
1573
+ return FAILURE ;
1569
1574
}
1570
1575
/* }}} */
1571
1576
0 commit comments