summaryrefslogtreecommitdiff
path: root/source/fitz/document.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-01-07 13:49:17 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-01-08 13:00:45 +0100
commit948afc03e1385b1a26eaede946b67daace0376f4 (patch)
tree6703070465ab56770ec7b7800cbc1e8012a6d7d8 /source/fitz/document.c
parentd06a3d89a455625cddec47f20cb7a4ef8ea60904 (diff)
downloadmupdf-948afc03e1385b1a26eaede946b67daace0376f4.tar.xz
pdf: Fix pdf_annot memory leak.
Diffstat (limited to 'source/fitz/document.c')
-rw-r--r--source/fitz/document.c14
1 files changed, 6 insertions, 8 deletions
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);
}
}