diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2016-04-26 14:08:09 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-05-13 11:42:00 +0200 |
commit | 21116fe869b3e377bc4560597b54eff3c3eacfdf (patch) | |
tree | e97e47562045452ab4e9efdc599780577c887769 /source | |
parent | b994d72069d761c8645cc6a0638bde21109c0b40 (diff) | |
download | mupdf-21116fe869b3e377bc4560597b54eff3c3eacfdf.tar.xz |
Make document handler reference counting thread-safe.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/document.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/fitz/document.c b/source/fitz/document.c index 52408ae3..227c93e1 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -26,8 +26,7 @@ fz_document_handler_context *fz_keep_document_handler_context(fz_context *ctx) { if (!ctx || !ctx->handler) return NULL; - ctx->handler->refs++; - return ctx->handler; + return fz_keep_imp(ctx, ctx->handler, &ctx->handler->refs); } void fz_drop_document_handler_context(fz_context *ctx) @@ -35,11 +34,11 @@ void fz_drop_document_handler_context(fz_context *ctx) if (!ctx || !ctx->handler) return; - if (--ctx->handler->refs != 0) - return; - - fz_free(ctx, ctx->handler); - ctx->handler = NULL; + if (fz_drop_imp(ctx, ctx->handler, &ctx->handler->refs)) + { + fz_free(ctx, ctx->handler); + ctx->handler = NULL; + } } void fz_register_document_handler(fz_context *ctx, const fz_document_handler *handler) |