summaryrefslogtreecommitdiff
path: root/backend/dvi/mdvi-lib/pk.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/dvi/mdvi-lib/pk.c')
-rw-r--r--backend/dvi/mdvi-lib/pk.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/backend/dvi/mdvi-lib/pk.c b/backend/dvi/mdvi-lib/pk.c
index a5791869..3e7d9661 100644
--- a/backend/dvi/mdvi-lib/pk.c
+++ b/backend/dvi/mdvi-lib/pk.c
@@ -469,6 +469,15 @@ static int pk_load_font(DviParams *unused, DviFont *font)
}
if(feof(p))
break;
+
+ /* Although the PK format support bigger char codes,
+ * XeTeX and other extended TeX engines support charcodes up to
+ * 65536, while normal TeX engine supports only charcode up to 255.*/
+ if (cc < 0 || cc > 65536) {
+ mdvi_error (_("%s: unexpected charcode (%d)\n"),
+ font->fontname,cc);
+ goto error;
+ }
if(cc < loc)
loc = cc;
if(cc > hic)
@@ -512,7 +521,7 @@ static int pk_load_font(DviParams *unused, DviFont *font)
}
/* resize font char data */
- if(loc > 0 || hic < maxch-1) {
+ if(loc > 0 && hic < maxch-1) {
memmove(font->chars, font->chars + loc,
(hic - loc + 1) * sizeof(DviFontChar));
font->chars = xresize(font->chars,