PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_buffer_t *buf, const char *string, size_t length)
{
+ int free_buf = !!buf;
+
if ((buf = php_http_buffer_init(buf))) {
if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, string, length)) {
- pefree(buf, buf->pmem);
+ if (free_buf) {
+ pefree(buf, buf->pmem);
+ }
buf = NULL;
}
}
}
inflateEnd(&Z);
- if (decoded_len && *decoded) {
+ if (*decoded_len && *decoded) {
efree(*decoded);
}
}
zval_ptr_dtor(&zoption);
}
- if (ret != SUCCESS) {
- return ret;
- }
-
if ((zoption = get_option(options, ZEND_STRL("responseCode") TSRMLS_CC))) {
zval *zoption_copy = php_http_ztyp(IS_LONG, zoption);
#ifdef PHP_HTTP_HAVE_HASH
const php_hash_ops *eho = NULL;
- if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
+ if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
eho->hash_final(digest, e->ctx);
etag = php_http_etag_digest(digest, eho->digest_size);
}
#ifdef PHP_HTTP_HAVE_HASH
const php_hash_ops *eho = NULL;
- if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
+ if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
eho->hash_update(e->ctx, (const unsigned char *) data_ptr, data_len);
}
#endif
nxt = ptr->next;
php_stream_bucket_unlink(ptr TSRMLS_CC);
- php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len);
+ if (SUCCESS != php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len)) {
+ return PSFS_ERR_FATAL;
+ }
#if DBG_FILTER
fprintf(stderr, "update: deflate (-> %zu) (w: %zu, r: %zu)\n", encoded_len, stream->writepos, stream->readpos);
char *encoded = NULL;
size_t encoded_len = 0;
- php_http_encoding_stream_flush(buffer, &encoded, &encoded_len);
+ if (SUCCESS != php_http_encoding_stream_flush(buffer, &encoded, &encoded_len)) {
+ return PSFS_ERR_FATAL;
+ }
#if DBG_FILTER
fprintf(stderr, "flush: deflate (-> %zu)\n", encoded_len);
char *encoded = NULL;
size_t encoded_len = 0;
- php_http_encoding_stream_finish(buffer, &encoded, &encoded_len);
+ if (SUCCESS != php_http_encoding_stream_finish(buffer, &encoded, &encoded_len)) {
+ return PSFS_ERR_FATAL;
+ }
#if DBG_FILTER
fprintf(stderr, "finish: deflate (-> %zu)\n", encoded_len);
if (c > 1) {
php_http_message_t *tmp = msg, **arr;
- arr = ecalloc(c, sizeof(**arr));
+ arr = ecalloc(c, sizeof(*arr));
for (i = 0; i < c; ++i) {
arr[i] = tmp;
tmp = tmp->parent;
php_http_message_object_t **objects;
int last;
- objects = ecalloc(i, sizeof(**objects));
+ objects = ecalloc(i, sizeof(*objects));
/* we are the first message */
objects[0] = obj;