X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_buffer.c;h=6636e2c7dcfecd39a7e8b18bbdc45f00e1bd9e0e;hp=35155e7ced05fc676a08ef6b2ba018878c446e18;hb=22ba22a6bd587683a235e8a7af6958aec0516b45;hpb=2240fb6678019ad6b5dc9c37cfb454f5e57600bd diff --git a/php_http_buffer.c b/php_http_buffer.c index 35155e7..6636e2c 100644 --- a/php_http_buffer.c +++ b/php_http_buffer.c @@ -103,7 +103,7 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_shrink(php_http_buffer_t *buf) PHP_HTTP_BUFFER_API size_t php_http_buffer_append(php_http_buffer_t *buf, const char *append, size_t append_len) { - if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, append_len)) { + if (buf->free < append_len && PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, append_len)) { return PHP_HTTP_BUFFER_NOMEM; } memcpy(buf->data + buf->used, append, append_len); @@ -160,7 +160,7 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_cut(php_http_buffer_t *buf, size_t of PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_fix(php_http_buffer_t *buf) { - if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize_ex(buf, 1, 1, 0)) { + if (buf->free < 1 && PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize_ex(buf, 1, 1, 0)) { return NULL; } buf->data[buf->used] = '\0'; @@ -229,7 +229,7 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s, while ((got = php_http_buffer_chunk_buffer(s, data, data_len, &chunk, chunk_len))) { if (PHP_HTTP_BUFFER_PASS0 == passout(opaque, chunk, got TSRMLS_CC)) { - STR_SET(chunk, NULL); + PTR_SET(chunk, NULL); return PHP_HTTP_BUFFER_PASS0; } ++passed; @@ -240,9 +240,9 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s, } data = NULL; data_len = 0; - STR_SET(chunk, NULL); + PTR_SET(chunk, NULL); } - STR_FREE(chunk); + PTR_FREE(chunk); return passed; }