summaryrefslogtreecommitdiff
path: root/pango/modules.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-03-01 19:26:39 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-03-01 19:26:39 +0000
commitd78c3e7a162c8f3f82f6c12f16aca7cb60e0e1d9 (patch)
tree27dd1d095fd7fe63b587e2f2a34e61fcdc93f318 /pango/modules.c
parenta67f95fab9d47a86a2b4e84c48e31af1e7f44f5b (diff)
downloadpango-d78c3e7a162c8f3f82f6c12f16aca7cb60e0e1d9.tar.gz
Don't crash on out-of-BMP values.
Fri Mar 1 14:25:22 2002 Owen Taylor <otaylor@redhat.com> * pango/modules.c: Don't crash on out-of-BMP values. * pango/mini-fribidi/fribidi_get_type.c (_pango_fribidi_get_type): Return FRIBIDI_TYPE_LTR for all non-BMP characters.
Diffstat (limited to 'pango/modules.c')
-rw-r--r--pango/modules.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/pango/modules.c b/pango/modules.c
index f280920f..b4346f4c 100644
--- a/pango/modules.c
+++ b/pango/modules.c
@@ -500,7 +500,7 @@ build_map (PangoMapInfo *info)
init_modules();
info->map = map = g_new (PangoMap, 1);
- map->n_submaps = 0;
+ map->n_submaps = 256;
for (i=0; i<256; i++)
{
map->submaps[i].is_leaf = TRUE;
@@ -530,8 +530,18 @@ PangoMapEntry *
pango_map_get_entry (PangoMap *map,
guint32 wc)
{
- PangoSubmap *submap = &map->submaps[wc / 256];
- return submap->is_leaf ? &submap->d.entry : &submap->d.leaves[wc % 256];
+ int i = wc / 256;
+
+ if (i < map->n_submaps)
+ {
+ PangoSubmap *submap = &map->submaps[i];
+ return submap->is_leaf ? &submap->d.entry : &submap->d.leaves[wc % 256];
+ }
+ else
+ {
+ static PangoMapEntry default_entry = { NULL, FALSE };
+ return &default_entry;
+ }
}
/**
@@ -549,11 +559,18 @@ PangoEngine *
pango_map_get_engine (PangoMap *map,
guint32 wc)
{
- PangoSubmap *submap = &map->submaps[wc / 256];
- PangoMapEntry *entry = submap->is_leaf ? &submap->d.entry : &submap->d.leaves[wc % 256];
+ int i = wc / 256;
- if (entry->info)
- return pango_engine_pair_get_engine ((PangoEnginePair *)entry->info);
+ if (i < map->n_submaps)
+ {
+ PangoSubmap *submap = &map->submaps[i];
+ PangoMapEntry *entry = submap->is_leaf ? &submap->d.entry : &submap->d.leaves[wc % 256];
+
+ if (entry->info)
+ return pango_engine_pair_get_engine ((PangoEnginePair *)entry->info);
+ else
+ return NULL;
+ }
else
return NULL;
}