summaryrefslogtreecommitdiff
path: root/source/fitz/filter-thunder.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/fitz/filter-thunder.c')
-rw-r--r--source/fitz/filter-thunder.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/source/fitz/filter-thunder.c b/source/fitz/filter-thunder.c
index 82d313a0..db96fbeb 100644
--- a/source/fitz/filter-thunder.c
+++ b/source/fitz/filter-thunder.c
@@ -116,36 +116,28 @@ static void
close_thunder(fz_context *ctx, void *state_)
{
fz_thunder *state = (fz_thunder *)state_;
- fz_stream *chain = state->chain;
-
+ fz_drop_stream(ctx, state->chain);
fz_free(ctx, state->buffer);
fz_free(ctx, state);
- fz_drop_stream(ctx, chain);
}
fz_stream *
fz_open_thunder(fz_context *ctx, fz_stream *chain, int w)
{
- fz_thunder *state = NULL;
-
- fz_var(state);
-
+ fz_thunder *state = fz_malloc_struct(ctx, fz_thunder);
fz_try(ctx)
{
- state = fz_malloc_struct(ctx, fz_thunder);
- state->chain = chain;
state->run = 0;
state->pixel = 0;
state->lastpixel = 0;
state->len = w / 2;
state->buffer = fz_malloc(ctx, state->len);
+ state->chain = fz_keep_stream(ctx, chain);
}
fz_catch(ctx)
{
fz_free(ctx, state);
- fz_drop_stream(ctx, chain);
fz_rethrow(ctx);
}
-
return fz_new_stream(ctx, state, next_thunder, close_thunder);
}