+--------------------------------------------------------------------+
*/
-#include "php.h"
+#include "php_http_api.h"
#include "php_http_buffer.h"
PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(
) {
return PHP_HTTP_BUFFER_NOMEM;
}
- memcpy(buf->data + buf->used, append, append_len);
- buf->used += append_len;
- buf->free -= append_len;
+ if (append_len) {
+ memcpy(buf->data + buf->used, append, append_len);
+ buf->used += append_len;
+ buf->free -= append_len;
+ }
return append_len;
}
char **into, size_t *len)
{
char *copy = ecalloc(1, buf->used + 1);
- memcpy(copy, buf->data, buf->used);
+ if (buf->data) {
+ memcpy(copy, buf->data, buf->used);
+ }
if (into) {
*into = copy;
}