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