fix http\message\Body::toCallback
authorMichael Wallner <mike@php.net>
Sat, 14 Jan 2012 13:59:56 +0000 (13:59 +0000)
committerMichael Wallner <mike@php.net>
Sat, 14 Jan 2012 13:59:56 +0000 (13:59 +0000)
php_http_message_body.c

index b2d4ff8fb98efacc3c6940a8844545d2aec53021..14486a9edaeb7240f0ae0315d649428080849839 100644 (file)
@@ -554,8 +554,8 @@ PHP_METHOD(HttpMessageBody, toStream)
 
 struct fcd {
        zval *fcz;
-       zend_fcall_info *fci;
-       zend_fcall_info_cache *fcc;
+       zend_fcall_info fci;
+       zend_fcall_info_cache fcc;
 #ifdef ZTS
        void ***ts;
 #endif
@@ -569,9 +569,9 @@ static size_t pass(void *cb_arg, const char *str, size_t len)
 
        MAKE_STD_ZVAL(zdata);
        ZVAL_STRINGL(zdata, str, len, 1);
-       if (SUCCESS == zend_fcall_info_argn(fcd->fci TSRMLS_CC, 2, fcd->fcz, zdata)) {
-               zend_fcall_info_call(fcd->fci, fcd->fcc, NULL, NULL TSRMLS_CC);
-               zend_fcall_info_args_clear(fcd->fci, 0);
+       if (SUCCESS == zend_fcall_info_argn(&fcd->fci TSRMLS_CC, 2, &fcd->fcz, &zdata)) {
+               zend_fcall_info_call(&fcd->fci, &fcd->fcc, NULL, NULL TSRMLS_CC);
+               zend_fcall_info_args_clear(&fcd->fci, 0);
        }
        zval_ptr_dtor(&zdata);
        return len;
@@ -579,14 +579,19 @@ static size_t pass(void *cb_arg, const char *str, size_t len)
 
 PHP_METHOD(HttpMessageBody, toCallback)
 {
-       struct fcd fcd;
+       struct fcd fcd = {0};
        long offset = 0, forlen = 0;
 
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f|ll", &fcd.fci, &fcd.fcc, &offset, &forlen)) {
                php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+
                fcd.fcz = getThis();
                Z_ADDREF_P(fcd.fcz);
+               TSRMLS_SET_CTX(fcd.ts);
+
                php_http_message_body_to_callback(obj->body, pass, &fcd, offset, forlen);
+               zend_fcall_info_args_clear(&fcd.fci, 1);
+
                zval_ptr_dtor(&fcd.fcz);
                RETURN_TRUE;
        }