diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2012-08-05 20:01:04 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2012-08-06 14:03:10 +0200 |
commit | 697c3cfb34d0b6fe315fc4d303340275ab80c121 (patch) | |
tree | efaa27a3c7a62f36434587a9bfa9ce17f68d50b1 | |
parent | 0fda4705b3194d2158f4dd3998981884cb3e8570 (diff) | |
download | mupdf-697c3cfb34d0b6fe315fc4d303340275ab80c121.tar.xz |
Fix comparison of cmap table length against maximum value
The cmap table length counts how many entries there are currently in
the table. The table length was previously tested against USHRT_MAX
which is 65535. However, the desired value to compare with was 65536
which would be the maximum number of entries allowed in a cmap table.
All comparisons of the cmap table length are now using USHRT_MAX + 1.
-rw-r--r-- | pdf/pdf_cmap.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c index cd0d6385..d6cb3103 100644 --- a/pdf/pdf_cmap.c +++ b/pdf/pdf_cmap.c @@ -184,7 +184,7 @@ pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, int low, int high, int n) static void add_table(fz_context *ctx, pdf_cmap *cmap, int value) { - if (cmap->tlen == USHRT_MAX) + if (cmap->tlen >= USHRT_MAX + 1) { fz_warn(ctx, "cmap table is full; ignoring additional entries"); return; @@ -233,7 +233,7 @@ pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *table, int int i; int high = low + len; int offset = cmap->tlen; - if (cmap->tlen + len >= USHRT_MAX) + if (cmap->tlen + len >= USHRT_MAX + 1) fz_warn(ctx, "cannot map range to table; table is full"); else { @@ -280,7 +280,7 @@ pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int low, int *values, int l return; } - if (cmap->tlen + len + 1 >= USHRT_MAX) + if (cmap->tlen + len + 1 >= USHRT_MAX + 1) fz_warn(ctx, "cannot map one to many; table is full"); else { @@ -314,7 +314,7 @@ pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap) qsort(cmap->ranges, cmap->rlen, sizeof(pdf_range), cmprange); - if (cmap->tlen == USHRT_MAX) + if (cmap->tlen >= USHRT_MAX + 1) { fz_warn(ctx, "cmap table is full; will not combine ranges"); return; |