@@ -157,6 +157,7 @@ static void _php_curl_close(zend_resource *rsrc TSRMLS_DC);
157
157
#define CAAL (s , v ) add_assoc_long_ex(return_value, s, sizeof(s) - 1, (long) v);
158
158
#define CAAD (s , v ) add_assoc_double_ex(return_value, s, sizeof(s) - 1, (double) v);
159
159
#define CAAS (s , v ) add_assoc_string_ex(return_value, s, sizeof(s) - 1, (char *) (v ? v : ""));
160
+ #define CAASTR (s , v ) add_assoc_str_ex(return_value, s, sizeof(s) - 1, v? v : "");
160
161
#define CAAZ (s , v ) add_assoc_zval_ex(return_value, s, sizeof(s) -1 , (zval *) v);
161
162
162
163
#if defined(PHP_WIN32 ) || defined(__GNUC__ )
@@ -1587,12 +1588,11 @@ static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, v
1587
1588
php_curl * ch = (php_curl * )ctx ;
1588
1589
1589
1590
if (type == CURLINFO_HEADER_OUT ) {
1590
- if (ch -> header .str_len ) {
1591
- efree (ch -> header .str );
1591
+ if (ch -> header .str ) {
1592
+ STR_RELEASE (ch -> header .str );
1592
1593
}
1593
1594
if (buf_len > 0 ) {
1594
- ch -> header .str = estrndup (buf , buf_len );
1595
- ch -> header .str_len = buf_len ;
1595
+ ch -> header .str = STR_INIT (buf , buf_len , 0 );
1596
1596
}
1597
1597
}
1598
1598
@@ -1722,12 +1722,10 @@ static php_curl *alloc_curl_handle()
1722
1722
ch -> handlers -> fnmatch = NULL ;
1723
1723
#endif
1724
1724
1725
- ch -> header .str_len = 0 ;
1726
-
1727
1725
memset (& ch -> err , 0 , sizeof (struct _php_curl_error ));
1728
1726
1729
- zend_llist_init (& ch -> to_free -> str , sizeof (char * ), curl_free_string , 0 );
1730
- zend_llist_init (& ch -> to_free -> post , sizeof (struct HttpPost ), curl_free_post , 0 );
1727
+ zend_llist_init (& ch -> to_free -> str , sizeof (char * ), ( llist_dtor_func_t ) curl_free_string , 0 );
1728
+ zend_llist_init (& ch -> to_free -> post , sizeof (struct HttpPost ), ( llist_dtor_func_t ) curl_free_post , 0 );
1731
1729
ch -> safe_upload = 1 ; /* for now, for BC reason we allow unsafe API */
1732
1730
1733
1731
ch -> to_free -> slist = emalloc (sizeof (HashTable ));
@@ -2814,9 +2812,9 @@ PHP_FUNCTION(curl_setopt_array)
2814
2812
void _php_curl_cleanup_handle (php_curl * ch )
2815
2813
{
2816
2814
smart_str_free (& ch -> handlers -> write -> buf );
2817
- if (ch -> header .str_len ) {
2818
- efree (ch -> header .str );
2819
- ch -> header .str_len = 0 ;
2815
+ if (ch -> header .str ) {
2816
+ STR_RELEASE (ch -> header .str );
2817
+ ch -> header .str = NULL ;
2820
2818
}
2821
2819
2822
2820
memset (ch -> err .str , 0 , CURL_ERROR_SIZE + 1 );
@@ -2998,14 +2996,14 @@ PHP_FUNCTION(curl_getinfo)
2998
2996
CAAL ("local_port" , l_code );
2999
2997
}
3000
2998
#endif
3001
- if (ch -> header .str_len > 0 ) {
3002
- CAAS ("request_header" , ch -> header .str );
2999
+ if (ch -> header .str ) {
3000
+ CAASTR ("request_header" , ch -> header .str );
3003
3001
}
3004
3002
} else {
3005
3003
switch (option ) {
3006
3004
case CURLINFO_HEADER_OUT :
3007
- if (ch -> header .str_len > 0 ) {
3008
- RETURN_STRINGL ( ch -> header .str , ch -> header . str_len );
3005
+ if (ch -> header .str ) {
3006
+ RETURN_STR ( STR_COPY ( ch -> header .str ) );
3009
3007
} else {
3010
3008
RETURN_FALSE ;
3011
3009
}
@@ -3187,8 +3185,8 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
3187
3185
zval_ptr_dtor (& ch -> handlers -> passwd );
3188
3186
#endif
3189
3187
zval_ptr_dtor (& ch -> handlers -> std_err );
3190
- if (ch -> header .str_len > 0 ) {
3191
- efree (ch -> header .str );
3188
+ if (ch -> header .str ) {
3189
+ STR_RELEASE (ch -> header .str );
3192
3190
}
3193
3191
3194
3192
zval_ptr_dtor (& ch -> handlers -> write_header -> stream );
0 commit comments