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