Permalink
Browse files

bugfix: we incorrectly returned 500 in body filters. bugfix: we forgo…

…t to check the returned pointer from ngx_calloc_buf in the body filter.
  • Loading branch information...
1 parent eac6080 commit 756e88da6227292f5321e59efa1dc07fec9d47d2 @agentzh agentzh committed Aug 8, 2012
Showing with 10 additions and 9 deletions.
  1. +10 −9 src/ngx_http_echo_filter.c
@@ -178,11 +178,10 @@ ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
dd("exec filter cmds for after body cmds");
rc = ngx_http_echo_exec_filter_cmds(r, ctx, conf->after_body_cmds,
- &ctx->next_after_body_cmd);
-
+ &ctx->next_after_body_cmd);
if (rc == NGX_ERROR || rc > NGX_OK) {
dd("FAILED: exec filter cmds for after body cmds");
- return rc;
+ return NGX_ERROR;
}
ctx->skip_filter = 1;
@@ -197,11 +196,15 @@ ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
buf = ngx_calloc_buf(r->pool);
+ if (buf == NULL) {
+ return NGX_ERROR;
+ }
+
buf->last_buf = 1;
cl = ngx_alloc_chain_link(r->pool);
if (cl == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return NGX_ERROR;
}
cl->next = NULL;
@@ -228,16 +231,14 @@ ngx_http_echo_exec_filter_cmds(ngx_http_request_t *r,
/* evaluate arguments for the current cmd (if any) */
if (cmd->args) {
computed_args = ngx_array_create(r->pool, cmd->args->nelts,
- sizeof(ngx_str_t));
-
+ sizeof(ngx_str_t));
if (computed_args == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return NGX_ERROR;
}
opts = ngx_array_create(r->pool, 1, sizeof(ngx_str_t));
-
if (opts == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return NGX_ERROR;
}
rc = ngx_http_echo_eval_cmd_args(r, cmd, computed_args, opts);

0 comments on commit 756e88d

Please sign in to comment.