From 90421d4cd157c743264643794a5522a1dd46eda9 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 6 Feb 2018 01:42:38 +0100 Subject: Bug 698990: Start new run of font width only if not at end. Previously, while at the very last glyph mupdf would allocate a new array for a run of distinct glyph widths and then not drop it while leaving the function. Now a new run of font widths is only started if not at the very last glyph. --- source/pdf/pdf-font.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/pdf') diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index c7aaa9fd..8ca89e93 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -1737,7 +1737,8 @@ pdf_add_cid_font_widths(fz_context *ctx, pdf_document *doc, pdf_font_desc *fontd /* End of same widths for consecutive ids. Current will * be pushed as prev. below during next iteration */ publish = 1; - run_obj = pdf_new_array(ctx, doc, 10); + if (curr_code < face->num_glyphs) + run_obj = pdf_new_array(ctx, doc, 10); new_state = FW_RUN; /* And the new first code is our current code */ new_first_code = curr_code; @@ -1802,9 +1803,12 @@ pdf_add_cid_font_widths(fz_context *ctx, pdf_document *doc, pdf_font_desc *fontd break; } - state = new_state; - first_code = new_first_code; - publish = 0; + if (curr_code < face->num_glyphs) + { + state = new_state; + first_code = new_first_code; + publish = 0; + } } prev_size = curr_size; -- cgit v1.2.3