@@ -600,7 +600,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
600
600
if (!Z_ISUNDEF (retval )) {
601
601
_php_curl_verify_handlers (ch , /* reporterror */ true);
602
602
/* TODO Check callback returns an int or something castable to int */
603
- length = zval_get_long (& retval );
603
+ length = php_curl_get_long (& retval );
604
604
}
605
605
606
606
zval_ptr_dtor (& argv [0 ]);
@@ -633,7 +633,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
633
633
if (!Z_ISUNDEF (retval )) {
634
634
_php_curl_verify_handlers (ch , /* reporterror */ true);
635
635
/* TODO Check callback returns an int or something castable to int */
636
- rval = zval_get_long (& retval );
636
+ rval = php_curl_get_long (& retval );
637
637
}
638
638
zval_ptr_dtor (& argv [0 ]);
639
639
zval_ptr_dtor (& argv [1 ]);
@@ -670,7 +670,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
670
670
if (!Z_ISUNDEF (retval )) {
671
671
_php_curl_verify_handlers (ch , /* reporterror */ true);
672
672
/* TODO Check callback returns an int or something castable to int */
673
- if (0 != zval_get_long (& retval )) {
673
+ if (0 != php_curl_get_long (& retval )) {
674
674
rval = 1 ;
675
675
}
676
676
}
@@ -708,7 +708,7 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
708
708
if (!Z_ISUNDEF (retval )) {
709
709
_php_curl_verify_handlers (ch , /* reporterror */ true);
710
710
/* TODO Check callback returns an int or something castable to int */
711
- if (0 != zval_get_long (& retval )) {
711
+ if (0 != php_curl_get_long (& retval )) {
712
712
rval = 1 ;
713
713
}
714
714
}
@@ -807,6 +807,7 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
807
807
}
808
808
} else {
809
809
zend_throw_error (NULL , "The CURLOPT_SSH_HOSTKEYFUNCTION callback must return either CURLKHMATCH_OK or CURLKHMATCH_MISMATCH" );
810
+ zval_ptr_dtor (& retval );
810
811
}
811
812
}
812
813
@@ -901,7 +902,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
901
902
if (!Z_ISUNDEF (retval )) {
902
903
// TODO: Check for valid int type for return value
903
904
_php_curl_verify_handlers (ch , /* reporterror */ true);
904
- length = zval_get_long (& retval );
905
+ length = php_curl_get_long (& retval );
905
906
}
906
907
zval_ptr_dtor (& argv [0 ]);
907
908
zval_ptr_dtor (& argv [1 ]);
@@ -1322,6 +1323,17 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
1322
1323
(* source -> clone )++ ;
1323
1324
}
1324
1325
1326
+ zend_long php_curl_get_long (zval * zv )
1327
+ {
1328
+ if (EXPECTED (Z_TYPE_P (zv ) == IS_LONG )) {
1329
+ return Z_LVAL_P (zv );
1330
+ } else {
1331
+ zend_long ret = zval_get_long (zv );
1332
+ zval_ptr_dtor (zv );
1333
+ return ret ;
1334
+ }
1335
+ }
1336
+
1325
1337
static size_t read_cb (char * buffer , size_t size , size_t nitems , void * arg ) /* {{{ */
1326
1338
{
1327
1339
struct mime_data_cb_arg * cb_arg = (struct mime_data_cb_arg * ) arg ;
0 commit comments