diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-07-13 12:37:48 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-07-20 17:18:58 +0100 |
commit | 6d006a43d50bcbfc20cbb574c6953cfcfe906208 (patch) | |
tree | 6553c7c2702d258dfa344dd9e2a07cce311845f4 | |
parent | 221915518d71c1ba3585addbe7cff49bba96f175 (diff) | |
download | mupdf-6d006a43d50bcbfc20cbb574c6953cfcfe906208.tar.xz |
Fix leak during text extraction.
MuPDF (the win32/linux viewer) leaks a span_soup each time it
is run, even if (seemingly to the user) no text extraction
operations are done.
This is because the view does a text extraction pass silently,
during which 'begin_page' is called for both page contents and
annotation contents. This causes a leak of a span_soup.
Change the implementation to allocate the span_soup just in time
instead.
-rw-r--r-- | source/fitz/stext-device.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 1bf1332b..80743fc6 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -760,6 +760,9 @@ fz_text_extract(fz_context *ctx, fz_text_device *dev, fz_text *text, const fz_ma if (text->len == 0) return; + if (dev->spans == NULL) + dev->spans = new_span_soup(ctx); + if (style->wmode == 0) { if (font->ft_face) @@ -1011,8 +1014,6 @@ fz_text_begin_page(fz_context *ctx, fz_device *dev, const fz_rect *mediabox, con tdev->page->mediabox = *mediabox; fz_transform_rect(&tdev->page->mediabox, ctm); - - tdev->spans = new_span_soup(ctx); } static void |