/* }}} */
/* {{{ php_iconv_stream_filter_append_bucket */
-static size_t php_iconv_stream_filter_append_bucket(
+static int php_iconv_stream_filter_append_bucket(
php_iconv_stream_filter *self,
php_stream *stream, php_stream_filter *filter,
php_stream_bucket_brigade *buckets_out,
}
out_buf_size = ocnt = prev_ocnt = initial_out_buf_size;
- out_buf = pd = pemalloc(out_buf_size, self->persistent);
+ if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {
+ return FAILURE;
+ }
+
+ pd = out_buf;
if (self->stub_len > 0) {
pt = self->stub;
if (new_out_buf_size < out_buf_size) {
/* whoa! no bigger buckets are sold anywhere... */
- new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self->persistent TSRMLS_CC);
+ if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
+ goto out_failure;
+ }
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
out_buf_size = ocnt = initial_out_buf_size;
- out_buf = pd = pemalloc(out_buf_size, self->persistent);
+ if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {
+ return FAILURE;
+ }
+ pd = out_buf;
} else {
- new_out_buf = perealloc(out_buf, new_out_buf_size, self->persistent);
+ if (NULL == (new_out_buf = perealloc(out_buf, new_out_buf_size, persistent))) {
+ if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
+ goto out_failure;
+ }
+
+ php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
+ return FAILURE;
+ }
pd = new_out_buf + (pd - out_buf);
ocnt += (new_out_buf_size - out_buf_size);
out_buf = new_out_buf;
if (new_out_buf_size < out_buf_size) {
/* whoa! no bigger buckets are sold anywhere... */
- new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self->persistent TSRMLS_CC);
+ if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
+ goto out_failure;
+ }
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
out_buf_size = ocnt = initial_out_buf_size;
- out_buf = pd = pemalloc(out_buf_size, self->persistent);
+ if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {
+ return FAILURE;
+ }
+ pd = out_buf;
} else {
- new_out_buf = perealloc(out_buf, new_out_buf_size, self->persistent);
+ if (NULL == (new_out_buf = perealloc(out_buf, new_out_buf_size, persistent))) {
+ if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
+ goto out_failure;
+ }
+
+ php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
+ return FAILURE;
+ }
pd = new_out_buf + (pd - out_buf);
ocnt += (new_out_buf_size - out_buf_size);
out_buf = new_out_buf;
}
if (out_buf_size - ocnt > 0) {
- new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self->persistent TSRMLS_CC);
+ if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
+ goto out_failure;
+ }
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
} else {
- pefree(out_buf, self->persistent);
+ pefree(out_buf, persistent);
}
*consumed += buf_len - icnt;
return SUCCESS;
out_failure:
- pefree(out_buf, self->persistent);
+ pefree(out_buf, persistent);
return FAILURE;
}
php_stream_bucket_unlink(bucket TSRMLS_CC);
- if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, bucket->buf, bucket->buflen, &consumed, self->persistent TSRMLS_CC) != SUCCESS) { goto out_failure;
+ if (php_iconv_stream_filter_append_bucket(self, stream, filter,
+ buckets_out, bucket->buf, bucket->buflen, &consumed,
+ php_stream_is_persistent(stream) TSRMLS_CC) != SUCCESS) {
+ goto out_failure;
}
php_stream_bucket_delref(bucket TSRMLS_CC);
}
if (flags != PSFS_FLAG_NORMAL) {
- if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, NULL, 0, &consumed, self->persistent TSRMLS_CC) != SUCCESS) {
+ if (php_iconv_stream_filter_append_bucket(self, stream, filter,
+ buckets_out, NULL, 0, &consumed,
+ php_stream_is_persistent(stream) TSRMLS_CC) != SUCCESS) {
goto out_failure;
}
}