@@ -624,7 +624,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
624
624
if (!Z_ISUNDEF (retval )) {
625
625
_php_curl_verify_handlers (ch , /* reporterror */ true);
626
626
/* TODO Check callback returns an int or something castable to int */
627
- length = zval_get_long (& retval );
627
+ length = php_curl_get_long (& retval );
628
628
}
629
629
630
630
zval_ptr_dtor (& argv [0 ]);
@@ -657,7 +657,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
657
657
if (!Z_ISUNDEF (retval )) {
658
658
_php_curl_verify_handlers (ch , /* reporterror */ true);
659
659
/* TODO Check callback returns an int or something castable to int */
660
- rval = zval_get_long (& retval );
660
+ rval = php_curl_get_long (& retval );
661
661
}
662
662
zval_ptr_dtor (& argv [0 ]);
663
663
zval_ptr_dtor (& argv [1 ]);
@@ -694,7 +694,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
694
694
if (!Z_ISUNDEF (retval )) {
695
695
_php_curl_verify_handlers (ch , /* reporterror */ true);
696
696
/* TODO Check callback returns an int or something castable to int */
697
- if (0 != zval_get_long (& retval )) {
697
+ if (0 != php_curl_get_long (& retval )) {
698
698
rval = 1 ;
699
699
}
700
700
}
@@ -732,7 +732,7 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
732
732
if (!Z_ISUNDEF (retval )) {
733
733
_php_curl_verify_handlers (ch , /* reporterror */ true);
734
734
/* TODO Check callback returns an int or something castable to int */
735
- if (0 != zval_get_long (& retval )) {
735
+ if (0 != php_curl_get_long (& retval )) {
736
736
rval = 1 ;
737
737
}
738
738
}
@@ -831,6 +831,7 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
831
831
}
832
832
} else {
833
833
zend_throw_error (NULL , "The CURLOPT_SSH_HOSTKEYFUNCTION callback must return either CURLKHMATCH_OK or CURLKHMATCH_MISMATCH" );
834
+ zval_ptr_dtor (& retval );
834
835
}
835
836
}
836
837
@@ -925,7 +926,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
925
926
if (!Z_ISUNDEF (retval )) {
926
927
// TODO: Check for valid int type for return value
927
928
_php_curl_verify_handlers (ch , /* reporterror */ true);
928
- length = zval_get_long (& retval );
929
+ length = php_curl_get_long (& retval );
929
930
}
930
931
zval_ptr_dtor (& argv [0 ]);
931
932
zval_ptr_dtor (& argv [1 ]);
@@ -1343,6 +1344,17 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
1343
1344
(* source -> clone )++ ;
1344
1345
}
1345
1346
1347
+ zend_long php_curl_get_long (zval * zv )
1348
+ {
1349
+ if (EXPECTED (Z_TYPE_P (zv ) == IS_LONG )) {
1350
+ return Z_LVAL_P (zv );
1351
+ } else {
1352
+ zend_long ret = zval_get_long (zv );
1353
+ zval_ptr_dtor (zv );
1354
+ return ret ;
1355
+ }
1356
+ }
1357
+
1346
1358
static size_t read_cb (char * buffer , size_t size , size_t nitems , void * arg ) /* {{{ */
1347
1359
{
1348
1360
struct mime_data_cb_arg * cb_arg = (struct mime_data_cb_arg * ) arg ;
0 commit comments