summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-unicode.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2017-06-28 01:45:16 +0800
committerSebastian Rasmussen <sebras@gmail.com>2017-07-06 22:03:41 +0800
commit04915b552a7e193a887a337558abed8175d1ff1f (patch)
tree389c7e0173f1b7065924039466d0ac8e6c481714 /source/pdf/pdf-unicode.c
parent93202a5ef3948dd01ca7b5ae7dc4884b76582cd4 (diff)
downloadmupdf-04915b552a7e193a887a337558abed8175d1ff1f.tar.xz
pdf: Drop cmap object in case of exception.
Diffstat (limited to 'source/pdf/pdf-unicode.c')
-rw-r--r--source/pdf/pdf-unicode.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/source/pdf/pdf-unicode.c b/source/pdf/pdf-unicode.c
index 11b1aea8..c599b202 100644
--- a/source/pdf/pdf-unicode.c
+++ b/source/pdf/pdf-unicode.c
@@ -32,28 +32,36 @@ pdf_remap_cmap(fz_context *ctx, pdf_cmap *gid_from_cpt, pdf_cmap *ucs_from_cpt)
ucs_from_gid = pdf_new_cmap(ctx);
- if (gid_from_cpt->usecmap)
- ucs_from_gid->usecmap = pdf_remap_cmap(ctx, gid_from_cpt->usecmap, ucs_from_cpt);
-
- for (i = 0; i < gid_from_cpt->rlen; ++i)
+ fz_try(ctx)
{
- a = gid_from_cpt->ranges[i].low;
- b = gid_from_cpt->ranges[i].high;
- x = gid_from_cpt->ranges[i].out;
- pdf_remap_cmap_range(ctx, ucs_from_gid, a, x, b - a, ucs_from_cpt);
- }
+ if (gid_from_cpt->usecmap)
+ ucs_from_gid->usecmap = pdf_remap_cmap(ctx, gid_from_cpt->usecmap, ucs_from_cpt);
- for (i = 0; i < gid_from_cpt->xlen; ++i)
- {
- a = gid_from_cpt->xranges[i].low;
- b = gid_from_cpt->xranges[i].high;
- x = gid_from_cpt->xranges[i].out;
- pdf_remap_cmap_range(ctx, ucs_from_gid, a, x, b - a, ucs_from_cpt);
- }
+ for (i = 0; i < gid_from_cpt->rlen; ++i)
+ {
+ a = gid_from_cpt->ranges[i].low;
+ b = gid_from_cpt->ranges[i].high;
+ x = gid_from_cpt->ranges[i].out;
+ pdf_remap_cmap_range(ctx, ucs_from_gid, a, x, b - a, ucs_from_cpt);
+ }
- /* Font encoding CMaps don't have one-to-many mappings, so we can ignore the mranges. */
+ for (i = 0; i < gid_from_cpt->xlen; ++i)
+ {
+ a = gid_from_cpt->xranges[i].low;
+ b = gid_from_cpt->xranges[i].high;
+ x = gid_from_cpt->xranges[i].out;
+ pdf_remap_cmap_range(ctx, ucs_from_gid, a, x, b - a, ucs_from_cpt);
+ }
+
+ /* Font encoding CMaps don't have one-to-many mappings, so we can ignore the mranges. */
- pdf_sort_cmap(ctx, ucs_from_gid);
+ pdf_sort_cmap(ctx, ucs_from_gid);
+ }
+ fz_catch(ctx)
+ {
+ pdf_drop_cmap(ctx, ucs_from_gid);
+ fz_rethrow(ctx);
+ }
return ucs_from_gid;
}