@@ -1381,7 +1381,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1381
1381
postval = Z_STR_P (prop );
1382
1382
1383
1383
if (php_check_open_basedir (ZSTR_VAL (postval ))) {
1384
- return FAILURE ;
1384
+ goto out_string ;
1385
1385
}
1386
1386
1387
1387
prop = zend_read_property (curl_CURLFile_class , Z_OBJ_P (current ), "mime" , sizeof ("mime" )- 1 , 0 , & rv );
@@ -1407,15 +1407,16 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1407
1407
seekfunc = NULL ;
1408
1408
}
1409
1409
1410
+ part = curl_mime_addpart (mime );
1411
+ if (part == NULL ) {
1412
+ php_stream_close (stream );
1413
+ goto out_string ;
1414
+ }
1415
+
1410
1416
cb_arg = emalloc (sizeof * cb_arg );
1411
1417
cb_arg -> filename = zend_string_copy (postval );
1412
1418
cb_arg -> stream = stream ;
1413
1419
1414
- part = curl_mime_addpart (mime );
1415
- if (part == NULL ) {
1416
- zend_string_release_ex (string_key , 0 );
1417
- return FAILURE ;
1418
- }
1419
1420
if ((form_error = curl_mime_name (part , ZSTR_VAL (string_key ))) != CURLE_OK
1420
1421
|| (form_error = curl_mime_data_cb (part , filesize , read_cb , seekfunc , free_cb , cb_arg )) != CURLE_OK
1421
1422
|| (form_error = curl_mime_filename (part , filename ? filename : ZSTR_VAL (postval ))) != CURLE_OK
@@ -1449,8 +1450,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1449
1450
1450
1451
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "postname" , sizeof ("postname" )- 1 , 0 , & rv );
1451
1452
if (EG (exception )) {
1452
- zend_string_release_ex (string_key , 0 );
1453
- return FAILURE ;
1453
+ goto out_string ;
1454
1454
}
1455
1455
ZVAL_DEREF (prop );
1456
1456
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1459,8 +1459,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1459
1459
1460
1460
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "mime" , sizeof ("mime" )- 1 , 0 , & rv );
1461
1461
if (EG (exception )) {
1462
- zend_string_release_ex (string_key , 0 );
1463
- return FAILURE ;
1462
+ goto out_string ;
1464
1463
}
1465
1464
ZVAL_DEREF (prop );
1466
1465
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1469,8 +1468,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1469
1468
1470
1469
prop = zend_read_property (curl_CURLStringFile_class , Z_OBJ_P (current ), "data" , sizeof ("data" )- 1 , 0 , & rv );
1471
1470
if (EG (exception )) {
1472
- zend_string_release_ex (string_key , 0 );
1473
- return FAILURE ;
1471
+ goto out_string ;
1474
1472
}
1475
1473
ZVAL_DEREF (prop );
1476
1474
ZEND_ASSERT (Z_TYPE_P (prop ) == IS_STRING );
@@ -1483,8 +1481,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1483
1481
1484
1482
part = curl_mime_addpart (mime );
1485
1483
if (part == NULL ) {
1486
- zend_string_release_ex (string_key , 0 );
1487
- return FAILURE ;
1484
+ goto out_string ;
1488
1485
}
1489
1486
if ((form_error = curl_mime_name (part , ZSTR_VAL (string_key ))) != CURLE_OK
1490
1487
|| (form_error = curl_mime_data (part , ZSTR_VAL (postval ), ZSTR_LEN (postval ))) != CURLE_OK
@@ -1540,7 +1537,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1540
1537
1541
1538
SAVE_CURL_ERROR (ch , error );
1542
1539
if (error != CURLE_OK ) {
1543
- return FAILURE ;
1540
+ goto out_mime ;
1544
1541
}
1545
1542
1546
1543
if ((* ch -> clone ) == 1 ) {
@@ -1556,6 +1553,16 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
1556
1553
1557
1554
SAVE_CURL_ERROR (ch , error );
1558
1555
return error == CURLE_OK ? SUCCESS : FAILURE ;
1556
+
1557
+ out_string :
1558
+ zend_string_release_ex (string_key , false);
1559
+ out_mime :
1560
+ #if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
1561
+ curl_mime_free (mime );
1562
+ #else
1563
+ curl_formfree (first );
1564
+ #endif
1565
+ return FAILURE ;
1559
1566
}
1560
1567
/* }}} */
1561
1568
0 commit comments