common: Fix memory leak.

* common/iobuf.c (iobuf_set_partial_body_length_mode): Only create
context if necessary.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-06-30 17:29:19 +02:00
parent 9037c23979
commit d2d19063d3
1 changed files with 2 additions and 3 deletions

View File

@ -2530,9 +2530,6 @@ iobuf_get_fname_nonnull (iobuf_t a)
void
iobuf_set_partial_body_length_mode (iobuf_t a, size_t len)
{
block_filter_ctx_t *ctx = xcalloc (1, sizeof *ctx);
ctx->use = a->use;
if (!len)
/* Disable partial body length mode. */
{
@ -2546,6 +2543,8 @@ iobuf_set_partial_body_length_mode (iobuf_t a, size_t len)
else
/* Enabled partial body length mode. */
{
block_filter_ctx_t *ctx = xcalloc (1, sizeof *ctx);
ctx->use = a->use;
ctx->partial = 1;
ctx->size = 0;
ctx->first_c = len;