summaryrefslogtreecommitdiff
path: root/src/rufl_init.c
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2022-05-22 21:52:08 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2022-05-22 21:52:08 +0100
commit479cc6662a3a26a237a993290216f5257d031318 (patch)
tree1349105574854db8ffa86b2e003bf765255fb9dc /src/rufl_init.c
parente25cd523d0336286dcb43b17de3864399a55fd42 (diff)
downloadlibrufl-479cc6662a3a26a237a993290216f5257d031318.tar.gz
librufl-479cc6662a3a26a237a993290216f5257d031318.tar.bz2
Add a test for a broken encoding file
This file is broken in a number of ways: * It contains garbage content that does not form valid glyph name specifiers * It contains garbage directives * It tries to define more than 256 glyphs (which is not supported by non-UCS FontManagers) The latter point above uncovered a bug in the umap sanity checking where it failed to properly count the number of glyph indices being defined by the Encoding file.
Diffstat (limited to 'src/rufl_init.c')
-rw-r--r--src/rufl_init.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/rufl_init.c b/src/rufl_init.c
index b7f4042..de3463a 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -1133,7 +1133,8 @@ static rufl_code rufl_init_umap_cb(void *pw, uint32_t glyph_idx, uint32_t ucs4)
rufl_code result = rufl_OK;
/* Ignore first 32 character codes (these are control chars) */
- if (glyph_idx > 31 && glyph_idx < 256 && umap->entries < 256) {
+ if (glyph_idx > 31 && glyph_idx < 256 && umap->entries < 256 &&
+ ucs4 != (uint32_t) -1) {
umap->map[umap->entries].u = ucs4;
umap->map[umap->entries].c = glyph_idx;
umap->entries++;
@@ -1141,7 +1142,7 @@ static rufl_code rufl_init_umap_cb(void *pw, uint32_t glyph_idx, uint32_t ucs4)
/* Stash the total number of encoding file entries so that
* rufl_init_scan_font_in_encoding can detect the presence of a
* UCS font on a non-UCS capable system. It will clean up for us. */
- umap->encoding = (void *) (((uintptr_t) umap->encoding) + 1);
+ umap->encoding = (void *) ((uintptr_t) (glyph_idx + 1));
return result;
}
@@ -1276,6 +1277,9 @@ static rufl_code emit_codepoint(char s[200], unsigned int i,
if (result != rufl_OK)
break;
}
+ } else {
+ /* No mapping: inform callback in case it cares */
+ result = callback(pw, i, (uint32_t) -1);
}
return result;