Leave chain in ngx_chain_add_copy() in consistent state on errors.
diff --git a/src/core/ngx_buf.c b/src/core/ngx_buf.c
index 1862a06..c3783c4 100644
--- a/src/core/ngx_buf.c
+++ b/src/core/ngx_buf.c
@@ -137,6 +137,7 @@
     while (in) {
         cl = ngx_alloc_chain_link(pool);
         if (cl == NULL) {
+            *ll = NULL;
             return NGX_ERROR;
         }