summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-cmap.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-01-22 14:55:50 +0100
committerTor Andersson <tor.andersson@artifex.com>2014-01-22 14:56:06 +0100
commit40488b4969ae4ae1f6ec72c6e1faa3a1e374b0a7 (patch)
tree8bbfce0cbcb01ce6df768f0a5f2382fafa1bf2e6 /source/pdf/pdf-cmap.c
parent05242bb1d3badf5e71b2e5d6464dfbd53b3b39b3 (diff)
downloadmupdf-40488b4969ae4ae1f6ec72c6e1faa3a1e374b0a7.tar.xz
Handle cmap table overflow gracefully in range-to-table mappings.
Diffstat (limited to 'source/pdf/pdf-cmap.c')
-rw-r--r--source/pdf/pdf-cmap.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/source/pdf/pdf-cmap.c b/source/pdf/pdf-cmap.c
index 025d4659..5bd8c7fb 100644
--- a/source/pdf/pdf-cmap.c
+++ b/source/pdf/pdf-cmap.c
@@ -240,16 +240,17 @@ pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *table, int
int high = low + len;
int offset = cmap->tlen;
if (cmap->tlen + len >= USHRT_MAX + 1)
- fz_warn(ctx, "cannot map range to table; table is full");
+ {
+ /* no space in the table; emit as a set of single lookups instead */
+ for (i = 0; i < len; i++)
+ add_range(ctx, cmap, low + i, low + i, PDF_CMAP_SINGLE, table[i]);
+ }
else
{
- int fail = 0;
+ /* add table cannot fail here, we already checked that it will fit */
for (i = 0; i < len; i++)
- fail |= add_table(ctx, cmap, table[i]);
- if (!fail)
- add_range(ctx, cmap, low, high, PDF_CMAP_TABLE, offset);
- else
- cmap->tlen = offset;
+ add_table(ctx, cmap, table[i]);
+ add_range(ctx, cmap, low, high, PDF_CMAP_TABLE, offset);
}
}
@@ -302,7 +303,7 @@ pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int low, int *values, int l
if (!fail)
add_range(ctx, cmap, low, low, PDF_CMAP_MULTI, offset);
else
- cmap->tlen = offset;
+ cmap->tlen = offset; /* ignore one-to-many mappings when the table is full */
}
}