From 948afc03e1385b1a26eaede946b67daace0376f4 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 7 Jan 2016 13:49:17 +0100 Subject: pdf: Fix pdf_annot memory leak. --- source/fitz/document.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source/fitz/document.c') diff --git a/source/fitz/document.c b/source/fitz/document.c index 319ac83b..4cc5dbba 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -364,9 +364,9 @@ fz_run_page(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *tra void * fz_new_annot(fz_context *ctx, int size) { - fz_page *page = Memento_label(fz_calloc(ctx, 1, size), "fz_annot"); - page->refs = 1; - return page; + fz_annot *annot = Memento_label(fz_calloc(ctx, 1, size), "fz_annot"); + annot->refs = 1; + return annot; } fz_annot * @@ -380,13 +380,11 @@ fz_keep_annot(fz_context *ctx, fz_annot *annot) void fz_drop_annot(fz_context *ctx, fz_annot *annot) { - if (annot) + if (annot && --annot->refs == 0) { - if (--annot->refs == 0 && annot->drop_annot_imp) - { + if (annot->drop_annot_imp) annot->drop_annot_imp(ctx, annot); - fz_free(ctx, annot); - } + fz_free(ctx, annot); } } -- cgit v1.2.3